厦大ACM入门百练

统计字符个数初步

描述

作为新编程文化运动的先行者,小鲁立志改变人对文化人是编程盲的刻板印象,他立志解决各种文字处理领域的难题。

为了将来能够海量的文本中统计出合乎文学特征的样本,小鲁开始尝试统计文本中的字符个数。

伟大的变革,往往有个很卑微的开始。这是小鲁往文本识别领域迈出的一小步:

给定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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值