Problem Description
Count the number of each vowel that appears in the string.
Input
Input data comprises a first integer n, the number of test cases, and n is the string length does not exceed the line 100.
Output
Test Example 5 For each output line, the following format:
A: num1
E: num2
I: num3
O: Num4
U: Num5
between a plurality of test cases separated by a blank line.
Please pay particular attention to: the last piece of the output is not followed by a blank line :)
A: num1
E: num2
I: num3
O: Num4
U: Num5
between a plurality of test cases separated by a blank line.
Please pay particular attention to: the last piece of the output is not followed by a blank line :)
Sample Input
2 aeiou my name is ignatius
Sample Output
to 1 and 1 i: 1: 1 u 1 a: 2 and 1 i: 3: u 0: 1
Author
lcy
Source
Recommend
Note: Press Enter after scanf input will buffer, and then later enter the required character or string before using getchar () Enter this absorbed.
And gets () string will \ n as the end, when carriage return is pressed itself will absorb, and therefore the rear or input character string and then, without first absorption getchar ().
C language code as follows:
#include<stdio.h> int main() { int n=0; int a,e,i1,o,u; char s[100]; scanf("%d",&n); getchar(); for(int i=0;i<n;i++) { a=e=i1=o=u=0; gets(s); for(int j=0;s[j]!='\0';j++) { if(s[j]=='a') a++; else if(s[j]=='e') e++; else if(s[j]=='i') i1++; else if(s[j]=='o') o++; else if(s[j]=='u') u++; } if(i==n-1) printf("a:%d\ne:%d\ni:%d\no:%d\nu:%d\n",a,e,i1,o,u); else printf("a:%d\ne:%d\ni:%d\no:%d\nu:%d\n\n",a,e,i1,o,u); } }