好像没有什么比三元更简单的表达式了吧。。。。
# include <iostream>
int main()
{
using namespace std;
cout<<"Please enter one of the following choices:";
cout<<"c)carnivore\t"<<"p)paianist"
<<"t)tree\t"<<"q)game";
char c;
cout<<"please enter c,p,t or q:";
cin>>c;
while((c!='c')||(c!='p')||(c!='t')||(c!='q')){
switch(c)
{ case 'c' : cout<<"A maple is carnivore\t";
break;
case 'p' : cout<<"A maple is paianist\v";
break;
case 't' : cout<<"A maple is tree\t";
break;
case 'q' : cout<<"A maple is game\v";
break;
default : cout<<"please enter a c,p,t or q:";
}
cin>>c;
}
system("pause");
return 0;
}