题解 | #字符统计#
字符统计
http://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0
#include<stdio.h>
#include <string.h>
int main()
{
char str[1000];
int arr[130] = {0};
int max = 0;
scanf("%s", str);
for(int i=0; i<strlen(str); i++)
{
arr[str[i]]++;
max = max > arr[str[i]] ? max : arr[str[i]];
}
for(int i=max; i>0; i--)
{
for(int j = '0'; j < 'z'+ 1; j++)
{
if(arr[j] == i)
printf("%c", j);
}
}
return 0;
}