题目链接
题目描述
编程实现输入一个字符,当该字符为a时输出apple,当该字符为b时输出banana,当该字符为c时输出cat,否则输出no
Input
输入一个字符
Output
输出相应单词
Sample Input
t
Sample Output
no
思路
输入一个字符,当该字符为a时输出apple,当该字符为b时输出banana,当该字符为c时输出cat,否则输出no。
C++代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
char c;
while(cin >> c)
{
if(c == 'a') cout << "apple" << endl;
else if(c == 'b') cout << "banana" << endl;
else if(c == 'c') cout << "cat" << endl;
else cout << "no" << endl;
}
return 0;
}