统计字符个数初步
描述
作为新编程文化运动的先行者,小鲁立志改变人对文化人是编程盲的刻板印象,他立志解决各种文字处理领域的难题。
为了将来能够海量的文本中统计出合乎文学特征的样本,小鲁开始尝试统计文本中的字符个数。
伟大的变革,往往有个很卑微的开始。这是小鲁往文本识别领域迈出的一小步:
给定n行字符串,请统计每行字符串中元音aeiou出现的次数,并且输出各元音的出现次数的统计表。
数据范围:
0<n<1000
0<字符串长度<100000
输入
第一行为一个整数n,表示要统计的字符串行数。
从第二行开始到文件结尾是n行字符串
输出
n个元音出现次数统计表
每个统计表之间用空行隔开
最后一张统计表的结束没有空行
输入样例 1
5 To know wisdom and instruction; to perceive the words of understanding; To receive the instruction of wisdom, justice, and judgment, and equity; To give subtilty to the simple, to the young man knowledge and discretion. A wise man will hear, and will increase learning; and a man of understanding shall attain unto wise counsels: To understand a proverb, and the interpretation; the words of the wise, and their dark sayings.
输出样例 1
a:2 e:5 i:5 o:7 u:2 a:2 e:7 i:6 o:4 u:4 a:2 e:7 i:5 o:6 u:2 a:13 e:8 i:8 o:3 u:3 a:7 e:9 i:5 o:5 u:1
#include <stdio.h>
#include <stdlib.h>
int main()
{
int N;
scanf("%d\n",&N);
for(int j=1;j<=N;j++)
{
char c[100000];
gets(c);
int n=strlen(c);
int count1=0,count2=0,count3=0,count4=0,count5=0;
for(int i=0;i<n;i++)
{
if(c[i]=='a'||c[i]=='A') count1++;
if(c[i]=='e'||c[i]=='E') count2++;
if(c[i]=='i'||c[i]=='I') count3++;
if(c[i]=='o'||c[i]=='O') count4++;
if(c[i]=='u'||c[i]=='U') count5++;
else continue;
}
if(j<N)
{
printf("a:%d\ne:%d\ni:%d\no:%d\nu:%d\n",count1,count2,count3,count4,count5);
printf("\n");
}
else printf("a:%d\ne:%d\ni:%d\no:%d\nu:%d",count1,count2,count3,count4,count5);
}
return 0;
}