原题:http://acm.hdu.edu.cn/showproblem.php?pid=1020
题意:计算字符串中各字母的个数,1不必标记;
#include<stdio.h>
#include<string.h>
char s[10005];
int main()
{
int cas;
scanf("%d", &cas);
while(cas--)
{
scanf("%s", s);
int len = strlen(s);
int con = 1;
for(int i = 0;i<len;i++)
{
if(s[i] != s[i+1])
{
if(con == 1)
printf("%c", s[i]);
else
printf("%d%c", con, s[i]);
con = 1;
}
else
con++;
}
printf("\n");
}
return 0;
}