几点收获:
枚举变量是整型的。(?)
记得给字符加单引号!
#include<iostream>
using namespace std;
void showmenu();
void main()
{
showmenu();
char choice;
cin>>choice;
while(choice!='c'&&choice!='p'&&choice!='t'&&choice!='g')
{
showmenu();
cin>>choice;
}
switch(choice)
{
case 'c':cout<<"Why don't you go to a carnivore?"<<endl;
break;
case 'p':cout<<"So you like music,huh?"<<endl;
break;
case 't':cout<<"Maple is a tree."<<endl;
break;
case 'g':cout<<"Don't play games any more!Sit down and study."<<endl;
break;
default:cout<<"Sorry that's not a choice,Please choose again."<<endl;
}
}
void showmenu()
{
cout<<"Please Enter your choice:\n"
"c:Carnivore p:Pianist\n"
"t:Tree g:Game\n";
}