#include <iostream>
using namespace std;
int main()
{
char ch;
cout << "Please enter one of the following choices:" << endl;
cout << "c) carnivore p) pianist" << endl;
cout << "t) tree g) game" << endl;
//while(1)
for( ; ; )
{
cin.get(ch);
cin.ignore();
if(ch == 'q')
{
cout << "退出程序。。。" << endl;
break;
}
switch(ch)
{
case 'c':
cout << "You select c" << endl;
break;
case 'p':
cout << "You select p" << endl;
break;
case 't':
cout << "You select t" << endl;
break;
case 'g':
cout << "You select g" << endl;
break;
default:
cout << "Please enter a , c , p , t , or g:" << endl;
break;
}
}
return 0;
}
编写一个菜单驱动程序的雏形。该程序显示一个提供4个选项的菜单——每个选项用一个字母标记。
最新推荐文章于 2024-05-31 21:36:31 发布