6.3
#include
using namespace std;
void main63()
{
cout<<”Please enter one of the following choices :”<<endl;
cout<<”c) carnivore p) pianist”<<endl;
cout<<”t) tree g) game”<<endl;
char ch;
//boolean
bool flag=true; //用于跳出循环
while(flag)
{
cout<<”\nPlease enter a a c,p,t,or g:”;
cin>>ch;
switch(ch)
{
case ‘c’:cout<<”A mape is a carnivore”,flag=false;break;
case ‘p’:cout<<”A mape is a pianist”,flag=false;break;
case ‘t’:cout<<”A mape is a tree”,flag=false;break;
case ‘g’:cout<<”A mape is a game”,flag=false;break;
default:;
}
}
system(“pause”);
}
- 本文作者: royalchen
- 本文链接: http://www.royalchen.com/2016/02/24/cprimerplus第六版课后编程题答案63/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!