HDU2027 统计元音

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 const int maxn = 205; //此处注意字符的ASCII码取值范围
 6 char s[maxn];
 7 int hash1[maxn];
 8 int main()
 9 {
10     int  n, flag;
11     scanf("%d", &n);
12     getchar(); //吃掉第一个回车
13     while(n--)
14     {
15         gets(s);
16         int len = strlen(s);
17         memset(hash1, 0, sizeof(hash1)); //别忘记初始化
18         for(int i = 0; i < len; i++) hash1[s[i]]++;
19         printf("a:%d\ne:%d\ni:%d\no:%d\nu:%d\n",hash1['a'], //字母要加单引号
20                hash1['e'],hash1['i'],hash1['o'],hash1['u']);
21         if(n) printf("\n"); //最后一组数据后没有空行
22     }
23     return 0;
24 }
View Code

 

posted on 2015-09-18 15:07  改写历史,倾尽天下  阅读(102)  评论(0编辑  收藏  举报

导航