显示部分的那些句子参考了答案!
#include <iostream>
using namespace std;
void showmenu();
int main()
{
//while(cin.get()!='/n');
char ch;
showmenu();
cin>>ch;
while(ch!='c'&&ch!='C'&&ch!='p'&&ch!='P'&&ch!='t'&&ch!='T'&&ch!='g'&&ch!='G')
{
while(cin.get()!='/n');
cout<<"Please enter a c, p, t or g: ";
cin>>ch;
}
switch(ch)
{
case 'c':
case 'C':cout<<"A cat is a carnivore./n";
break;
case 'p':
case 'P':cout<<"Radu Lupu is a pianist./n";
break;
case 't':
case 'T':cout<<"A maple is a tree./n";
break;
case 'g':
case 'G':cout<<"Golf is a game./n";
break;
default:cout<<"The program shouldn't get here!/n";
break;
}
return 0;
}
void showmenu()
{
cout<<"Please enter one of the following choices:/n"
<<"c) carnivore p) pianist/n"
<<"t) tree g) game/n";
}