首页 新闻 会员 周边

C++ 谢谢。。。。。

0
悬赏园豆:20 [已解决问题] 解决于 2020-12-01 07:21

Activity 7

Write a program that asks the user to enter a lowercase letter and determines whether or not the letter is a vowel. If the user enters a vowel, print “This is a vowel”, if the user enters a consonant, print “This is a consonant”. If the user enters the letter ‘y’, print “This is sometimes a vowel”. If the user enters anything other than a lowercase letter, print “Invalid input”.

活动7

编写一个程序,要求用户输入小写字母并确定该字母是否为元音。如果用户输入一个元音,则打印“这是一个元音”;如果用户输入一个辅音,则打印“这是一个辅音”。如果用户输入字母“ y”,则打印“有时是元音”。如果用户输入除小写字母之外的其他任何内容,请打印“无效输入”。

心律的主页 心律 | 初学一级 | 园豆:136
提问于:2020-12-01 00:17
< >
分享
最佳答案
0
#include <iostream>
using namespace std;

int main()
{
    char c;
    cout<<"Please input a letter: ";
    cin>>c;
    if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u')
    {
        cout<<"This is a vowel"<<endl;
    }
    else if(c=='y')
    {
        cout<<"This is sometimes a vowel"<<endl;
    }
    else if(c>='a' && c<='z')
    {
        cout<<"This is a consonant"<<endl;
    }
    else
    {
        cout<<"Invalid input"<<endl;
    }
    return 0;
}
展开代码内容
收获园豆:20
Conan-jine | 小虾三级 |园豆:1272 | 2020-12-01 00:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册