解题思路:
注意事项:
参考代码:
#include <iostream>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <string>
#include <cmath>
#include <cstdlib>
#include <string.h>
using namespace std;
int a[26];
int main()
{
char ch;
while((ch=cin.get())!='#')
{
if(ch=='\n'||ch==' ')
{
continue;
}
else if(ch=='a')
{
a[0]++;
}
else if(ch=='b')
{
a[1]++;
}
else if(ch=='c')
{
a[2]++;
}
else if(ch=='d')
{
a[3]++;
}
else if(ch=='e')
{
a[4]++;
}
else if(ch=='f')
{
a[5]++;
}
else if(ch=='g')
{
a[6]++;
}
else if(ch=='h')
{
a[7]++;
}
else if(ch=='i')
{
a[8]++;
}
else if(ch=='j')
{
a[9]++;
}
else if(ch=='k')
{
a[10]++;
}
else if(ch=='l')
{
a[11]++;
}
else if(ch=='m')
{
a[12]++;
}
else if(ch=='n')
{
a[13]++;
}
else if(ch=='o')
{
a[14]++;
}
else if(ch=='p')
{
a[15]++;
}
else if(ch=='q')
{
a[16]++;
}
else if(ch=='r')
{
a[17]++;
}
else if(ch=='s')
{
a[18]++;
}
else if(ch=='t')
{
a[19]++;
}
else if(ch=='u')
{
a[20]++;
}
else if(ch=='v')
{
a[21]++;
}
else if(ch=='w')
{
a[22]++;
}
else if(ch=='x')
{
a[23]++;
}
else if(ch=='y')
{
a[24]++;
}
else if(ch=='z')
{
a[25]++;
}
}
for(int i=0;i<26;i++)
{
printf("%c %d\n",'a'+i,a[i]);
}
return 0;
}
0.0分
0 人评分
九宫重排 (C++代码)浏览:1333 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:451 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:575 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:1097 |
WU-拆分位数 (C++代码)浏览:779 |
【偶数求和】 (C语言代码)浏览:431 |
printf基础练习2 (C语言代码)浏览:503 |
用筛法求之N内的素数。 (C语言代码)浏览:529 |
C二级辅导-等差数列 (C语言代码)浏览:810 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:742 |