• [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;
    }


  • 相关阅读:
    CentOS6.4 安装nmon
    CentOS6.4 访问域局网中Windows的共享
    将类似 12.56MB 36.89KB 转成 以K为单位的数字【备忘】
    ICE中间件相关
    HDFS介绍
    漫画描述HDFS工作原理
    离线安装Cloudera Manager 5和CDH5
    storm集群相关资料
    kafka相关资料
    jstatd
  • 原文地址:https://www.cnblogs.com/sxy201658506207/p/7586405.html
Copyright © 2020-2023  润新知