输入一个字符串,对字符串中的各个英文字符,数字,空格进行统计(可反复调用),按照统计个数的多少输出统计结果,如果统计的个数相同,则按照ACSII码由小到大排序输出。调用者会保证:输入的字符串以’ ’结尾
#include<iostream>
#include<algorithm>
using namespace std;
struct Count
{
int c;
int count;
};
bool cmp(const struct Count& a,const struct Count& b)
{
if(a.count==b.count)
return a.c<b.c;
else
return
a.count>b.count;
}
int main()
{
struct Count a[256];
char b[200];
for(int i=0;i<256;i++)
{
a[i].c=i;
a[i].count=0;
}
gets(b);
for(int i=0;b[i]!='