zoukankan      html  css  js  c++  java
  • [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;
    }


  • 相关阅读:
    解决Cannot download "https://github.com/sass/node-sass/releases/download/binding.nod的问题
    wid是一个字符串 必须转化成整型
    如何获取内联样式的width值
    onresize方法
    jquery中$("#afui").get(0)为什么要加get(0)呢?
    jquery $(document).ready() 与window.onload的区别
    鼠标点击
    添加二级菜单颜色
    homepage左边的导航菜单怎么做的?
    center
  • 原文地址:https://www.cnblogs.com/sxy201658506207/p/7586405.html
Copyright © 2011-2022 走看看