发个C++的switch例子
本帖最后由 明次 于 2009-6-7 20:55 编辑无聊随便乱写的....
#include <iostream>
using namespace std;
int main()
{
char ch;
cout <<" <1>我要喝茶\n";
cout <<" <2>我要喝奶\n";
cout <<" <3>我要看AV\n";
cout <<" <4>我想要money\n";
cout <<" <5>我要打飞机\n";
cout <<" <q>退出,什么也不选\n";
cout <<endl;
while (true)
{
cout <<"请随便选一个:";
cin>>ch;
switch(ch)
{
case '1':cout <<"拿钱来?1W块钱一瓶没钱请走人~\n";
break;
case '2':cout <<"找你妈要去!\n";
break;
case '3':cout <<"TMD..我还想看呢!\n";
break;
case '4':cout <<"叫声明次大哥我给你money\n";
break;
case '5':cout <<"自己打自己\n";
break;
case 'q':break;
default:cout <<"请选择彩单\n";
}
}
} 因为 代码中所有的break都只是跳出了switch,并没有跳出while. 恩,这个问题我刚已经解决了。还是谢谢你``
页:
[1]