• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
若忆_star
博客园    首页    新随笔    联系   管理    订阅  订阅
hdu 2027 统计元音

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2027

题目大意:水题~用多个数组,分别记录每个元音出现的次数。

 1 #include <stdio.h>
 2 int main ()
 3 {
 4     int i,n,num[5],m;
 5     char a[100];
 6     while (scanf("%d",&n)!=EOF)
 7     {
 8         getchar();
 9         while (n--)
10         {
11             num[0]=0;
12             num[1]=0;
13             num[2]=0;
14             num[3]=0;
15             num[4]=0;
16             gets(a);
17             for (i=0; a[i]!='\0'; i++)
18             {
19                 if (a[i]=='a')
20                     num[0]++;
21                 else if (a[i]=='e')
22                     num[1]++;
23                 else if (a[i]=='i')
24                     num[2]++;
25                 else if(a[i]=='o')
26                     num[3]++;
27                 else if(a[i]=='u')
28                     num[4]++;
29             }
30             printf("a:%d\n",num[0]);
31             printf("e:%d\n",num[1]);
32             printf("i:%d\n",num[2]);
33             printf("o:%d\n",num[3]);
34             printf("u:%d\n",num[4]);
35             if (n) putchar('\n');
36         }
37     }
38 }

 

posted on 2014-07-15 09:55  若忆_star  阅读(219)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3