Statistical vowelsTime
limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 45249 Accepted Submission (s): 18458
Problem description counts the number of occurrences of each vowel in a string.
Input data first consists of an integer n, which represents the number of test instances, followed by a string of n lines with a length of not more than 100.
Output outputs 5 rows for each test instance, in the following format:
A:num1
E:num2
I:num3
O:num4
U:num5
Multiple test instances are separated by a blank line.
Please pay special attention: There is no blank line after the last output:)
Sample Input
2aeioumy name is Ignatius
Sample Output
A:1e:1i:1o:1u:1a:2e:1i:3o:0u:1
#include <stdio.h>
#include <string.h>
Main ()
{
Char s[1000];
int i,j,k,n,a,b,c,d,e;
scanf ("%d", &n);
GetChar ();
k=n-1;
while (n--)
{a=0;
b=0;
c=0;
D=0;
e=0;
Gets (s);
J=strlen (s);
for (i=0;i<j;i++)
{
if (s[i]== ' a ')
a++;
if (s[i]== ' e ')
b++;
if (s[i]== ' I ')
C + +;
if (s[i]== ' O ')
d++;
if (s[i]== ' u ')
e++;
}
if (k--)
printf ("a:%d\ne:%d\ni:%d\no:%d\nu:%d\n\n", a,b,c,d,e);
else printf ("a:%d\ne:%d\ni:%d\no:%d\nu:%d\n", a,b,c,d,e);
}
return 0;
}
Statistical vowels of C language