解题思路:
字符数组用来作比较,数组用来计数。记得加判断
注意事项:
参考代码:
#include<iostream>
using namespace std;
#include<string>
int main()
{
string str="ABCDEFGHIGKLMNOPQRSTUVWXYZ";
string s;
int n;
int a[26];
for(int i=0;i<26;i++)
{
a[i]=0;
}
cin>>n;
while(n--)
{
cin>>s;
for(int i=0;i<s.length();i++)
{
for(int j=0;j<26;j++)
{
if(s[i]==str[j])
{
a[j]++;
}
}
}
for(int i=0;i<26;i++)
{
if(a[i]!=0)
{
if(a[i]==1)
{
cout<<str[i];
}
else
{
cout<<a[i]<<str[i];
}
}
}
cout<<endl;
for(int i=0;i<26;i++)
{
a[i]=0;
}
}
return 0;
}
0.0分
0 人评分
数字整除 (C++代码)——(22行代码)真的只需要两个变量就够了浏览:1808 |
拆分位数 (C++代码)用char简单粗暴,嗯浏览:1087 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:534 |
Tom数 (C++代码)浏览:828 |
Hello, world! (C语言代码)浏览:1201 |
printf基础练习2 (有点不明白)浏览:845 |
WU-蓝桥杯算法提高VIP-企业奖金发放 (C++代码)浏览:1176 |
【蟠桃记】 (C语言代码)浏览:664 |
剪刀石头布 (C语言代码)浏览:1755 |
WU-整除问题 (C++代码)浏览:612 |