#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int T;
string str;
int _count[26];
char cc;
int main()
{
cin>>T;
while(T--)
{
cin>>str;
memset(_count,0,sizeof(_count));
for(int i = 0;i < str.length(); i ++)
{
_count[str[i]-'A']++;
}
for(int i = 0; i < 26; i++)
{
cc= 'A'+i;
if(_count[i]!=0)
{
if(_count[i] == 1)
cout<<cc;
else
cout<<_count[i]<<cc;
}
}
if(T!=1)
cout<<endl;
}
return 0;
}hdu1020
最新推荐文章于 2019-09-17 21:06:21 发布
本文深入解析了一段使用C++实现的字符计数与输出代码,包括如何通过循环遍历字符串,利用数组存储每个字符出现次数,并根据不同次数输出不同格式的字符。代码示例适用于初学者理解C++基础操作。

793

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



