zoukankan      html  css  js  c++  java
  • HDU_2027——统计元音

    Problem Description
    统计每个元音字母在字符串中出现的次数。
     
    Input
    输入数据首先包括一个整数n,表示测试实例的个数,然后是n行长度不超过100的字符串。
     
    Output
    对于每个测试实例输出5行,格式如下:
    a:num1
    e:num2
    i:num3
    o:num4
    u:num5
    多个测试实例之间由一个空行隔开。

    请特别注意:最后一块输出后面没有空行:)
     
    Sample Input
    2 aeiou my name is ignatius
     
    Sample Output
    a:1 e:1 i:1 o:1 u:1 a:2 e:1 i:3 o:0 u:1
     1 #include <cstdio>
     2 #include <cctype>
     3 #include <cstring>
     4 int main()
     5 {
     6    int n,a[150];
     7    char str[101];
     8    scanf("%d",&n);
     9    getchar();
    10    while(n--)
    11       {
    12          gets(str);
    13          memset(a,0,sizeof(a));
    14          for(int j=0;str[j];j++)
    15             {
    16                if(isalpha(str[j]))
    17                   a[str[j]]++;
    18             }
    19          printf("a:%d
    e:%d
    i:%d
    o:%d
    u:%d
    ",a['a'],a['e'],a['i'],a['o'],a['u']);  
    20          if(n!=0) printf("
    ");
    21       }
    22    return 0;   
    23 }
    ——现在的努力是为了小时候吹过的牛B!!
  • 相关阅读:
    git
    oracle object_id和data_object_id的区别
    statspack系列8
    statspack系列7
    statspack系列6
    statspack系列5
    statspack系列4
    statspack系列3
    statspack系列2
    MySQL源码之两阶段提交
  • 原文地址:https://www.cnblogs.com/pingge/p/3142759.html
Copyright © 2011-2022 走看看