zoukankan      html  css  js  c++  java
  • 杭电2027--统计元音

    统计元音

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 46701    Accepted Submission(s): 19038


    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
     

     

    Author
    lcy
     

     

    Source
     

     

    Recommend
    lcy   |   We have carefully selected several similar problems for you:  1062 1256 1020 1075 2072 
     
     1 #include <stdio.h>
     2 #include <string.h>
     3 int main()
     4 {
     5     char str[110] ;
     6     int i, n ;
     7     while(~scanf("%d", &n))
     8     {
     9         getchar() ;  //为什么必须放在这边 ?
    10          while(n--)
    11         {
    12             gets(str) ;
    13             int len = strlen (str) ;
    14             int a=0, b=0, c=0, d=0, e=0 ;
    15             for(i=0; i<len; i++)
    16             {
    17                 if(str[i] == 'a')
    18                 a++ ;
    19                 if(str[i] == 'e')
    20                 b++ ;
    21                 if(str[i] == 'i')
    22                 c++ ;
    23                 if(str[i] == 'o')
    24                 d++ ;
    25                 if(str[i] == 'u')
    26                 e++ ;
    27             }
    28             printf("a:%d
    ",a) ;
    29             printf("e:%d
    ",b) ;
    30             printf("i:%d
    ",c) ;
    31             printf("o:%d
    ",d) ;
    32             printf("u:%d
    ",e) ;
    33             if(n!=0)
    34             printf("
    ") ;
    35         }
    36     }
    37     return 0 ;
    38 } 
  • 相关阅读:
    读取points文件
    JSP语法1
    servlet与SSI
    JDBC连接数据库
    django开发Blog(2)
    django开发Blog(1)
    JSP学习2:useBean动作标签
    django开发Blog(4)
    Servelet基础
    servlet会话管理2
  • 原文地址:https://www.cnblogs.com/soTired/p/4665372.html
Copyright © 2011-2022 走看看