题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1219
字符串,注意ASCⅡ码的转换,输入用 gets();
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
int main()
{
char a[1000005];
int ans[26];
while(gets(a))
{
memset(ans,0,sizeof(ans));
int l=strlen(a);
for(int i=0;i<l;i++)
if(a[i] >='a' && a[i] <= 'z')
{
ans[ a[i]-'a']++;
}
for(int i=0;i<26;i++)
printf("%c:%d\n",i+'a',ans[i]);
printf("\n");
}
return 0;
}