#include<iostream>
using namespace std;
int main(){
cout<<"please enter one of the following choices:\n";
cout<<"c) carrnivore"<<"\t"<<"p) pinist\n";
cout<<"t) tree"<<"\t"<<"g) game\n";
char choice;
cin>>choice;
while(choice!='c'&&choice!='p'&&choice!='t'&&choice!='g'){
cout<<"please enter a c, p, t, or g;";
cin>>choice;
cout<<"\n";
}
//while(choice=='c'||choice=='p'||choice=='t'||choice=='p'){
switch(choice){
case 'c' :cout<<"A maple is a carrnovore\n"; break;
case 'p' :cout<<"A maple is a pinist\n"; break;
case 't' :cout<<"A maple is a tree\n"; break;
case 'g' :cout<<"A maple is a game\n"; break;
}
return 0;
}
c++ primer plus 習題6.3(switch)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.