HDU 2027 统计元音 (吃回车的方法)

转载地址:http://blog.csdn.net/qq_32866009/article/details/50815400
题目:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=110412#problem/C

代码:

#include<stdio.h>
#include<string.h>

using namespace std;

int main()
{
    int t;
    scanf("%d\n",&t);       //新技能GET
    while(t--)
    {
        char a[105];
        //getchar();
        gets(a);
        int x=0,xx=0,xxx=0,y=0,yy=0;
        for(int i=0;i<strlen(a);i++)
        {
            if(a[i]=='a')
                x++;
            if(a[i]=='e')
                xx++;
            if(a[i]=='i')
                xxx++;
            if(a[i]=='o')
                y++;
            if(a[i]=='u')
                yy++;
        }
        printf("a:%d\ne:%d\ni:%d\no:%d\nu:%d\n",x,xx,xxx,y,yy);
        if(t)printf("\n");
    }
}

感谢宋学霸教我做题,爱你,么么。

你可能感兴趣的:(HDU)