[hdoj 1020]encoding 字串編碼
description
given a string containing only 'a' - 'z', we could encode it using the following method:
1. each sub-string containing k same characters should be encoded to "kx" where "x" is the only character in this sub-string.
2. if the length of the sub-string is 1, '1' should be ignored.
input
the first line contains an integer n (1 <= n <= 100) which indicates the number of test cases. the next n lines contain n strings. each string consists of only 'a' - 'z' and the length is less than 10000.
output
for each test case, output the encoded string in a line.
sample input
2abcabbccc
sample output
abca2b3c
思路: 一開始以為是輸出所有的相同的,所以wa了兩次,原來是子串的相同,要臨近的數才能組合一起。。。。。
我的**:
#include #include using namespace std;
int main()
for (i=0,count=1;i
#include #include int main(){
int n,i,num;
char str[10001];//題目要求是10000個字元,我們要開大一點
scanf("%d",&n);
while(n--){
num=1;
scanf("%s",str);
for(i=0;i
HDOJ 字串統計
problem description 對於給定的乙個字串,統計其中數字字元出現的次數。input 輸入資料有多行,第一行是乙個整數n,表示測試例項的個數,後面跟著n行,每行包括乙個由字母和數字組成的字串。output 對於每個測試例項,輸出該串中數值的個數,每個輸出佔一行。sample input...
c 字串編碼編碼 encoding 使用方法示例
unicode有四種編碼格式,utf 8,utf 16,utf 32,utf 7。字元編碼類,asciiencoding utf7encoding,unicodeencoding,utf32encoding。複製 如下 using system.collectio using system.text...
hdoj 2017 字串統計 字串
對於給定的乙個字串,統計其中數字字元出現的次數。輸入資料有多行,第一行是乙個整數n,表示測試例項的個數,後面跟著n行,每行包括乙個由字母和數字組成的字串。對於每個測試例項,輸出該串中數值的個數,每個輸出佔一行。2 asdfasdf123123asdfasdf asdf111111111asdfasd...