原题: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;
}

本文深入探讨了HDU在线评测系统中关于字符串处理的问题,具体阐述了如何通过C语言实现字符串中各字母计数的功能,并详细解释了代码逻辑与实现细节。
779

被折叠的 条评论
为什么被折叠?



