abbcccdddeeeee -→1a2b3c4d5e
- #include<iostream>
-
#include<string>
-
-
using namespace std;
-
int main()
-
{
-
char str[51];
-
char tmp[51];
-
-
while(gets(str)) {
-
int len = strlen(str);
-
int index = 0;
-
int count = 1;
-
-
for(int i = 0; i < len; i++) {
-
if(str[i] == str[i+1])
-
count ++;
-
else {
-
tmp[index++] = count + '0';
-
tmp[index++] = str[i];
-
count = 1;
-
}
-
}
-
tmp[index] = '\0';
-
strcpy(str,tmp);
-
cout << str << endl;
-
}
-
return 0;
-
}
阅读(402) | 评论(0) | 转发(0) |