[YTU]_2759( 字符串---统计元音)

Description

输入一行字符串,统计每个元音字母在字符串中出现的次数。

Input

输入长度不超过100的字符串。

Output

输出5行,格式如下: a:a元音字母在字符串中出现的次数e:e元音字母在字符串中出现的次数 i:i元音字母在字符串中出现的次数o:o元音字母在字符串中出现的次数u:u元音字母在字符串中出现的次数

Sample Input

my name is ignatius

Sample Output

a:2
e:1
i:3
o:0
u:1
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char string1[101];
    int i,a=0,b=0,c=0,d=0,e=0;
    gets(string1);
    for(i=0;string1[i]!=' ';i++)
    {
        if(string1[i]=='a')
            a++;
        if(string1[i]=='e')
           b++;
        if(string1[i]=='i')
           c++;
        if(string1[i]=='o')
           d++;
        if(string1[i]=='u')
           e++; 
       }
    cout<<"a:"<<a<<endl<<"e:"<<b<<endl<<"i:"<<c<<endl<<"o:"<<d<<endl<<"u:"<<e<<endl;
    return 0;
}
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char str[101];
	int i,q=0,w=0,y=0,r=0,p=0;
	gets(str);
	for(i=0;str[i]!=' ';i++)
	{
		switch(str[i])
		{
		case 'a':q++;break;
		case 'e':w++;break;
		case 'i':r++;break;
		case 'o':y++;break;
		case 'u':p++;break;
		case 'A':q++;break;
		case 'E':w++;break;
		case 'I':r++;break;
		case 'O':y++;break;
		case 'U':p++;break;
		}
	}
		cout<<"a:"<<q<<endl<<"e:"<<w<<endl<<"i:"<<r<<endl<<"o:"<<y<<endl<<"u:"<<p<<endl;
	return 0;
}