猜数字游戏
刚学C++,自己编了程序,还能运行,希望高手看看有梅有可以改进的地方!!!#include <iostream.h>
void main()
{
char ch,c='n';
while(1)
{
cout<<"-----press\'y\'to close this exe\n";
cin>>ch;
if(c=='y') break;
else
{
cout<<"请输入一个数字:0-9\n";
cin>>ch;
switch(ch)
{
case '0': cout<<"Sorry,you have nothing."<<endl; break;
case '9': cout<<"You have a long life."<<endl; break;
case '8': cout<<"Lucky number."<<endl; break;
case '7': cout<<"Sunday will make you happy."<<endl; break;
case '6': cout<<"Sing a song,Please."<<endl; break;
case '5': cout<<"Happy girl."<<endl; break;
case '4': cout<<"Nothing."<<endl; break;
case '3': cout<<"Good luck."<<endl; break;
case '2': cout<<"You are my best friend."<<endl; break;
case '1': cout<<"You are number one."<<endl; break;
default: cout<<"The character is not between 0 and 9."<<endl;
}
}
}
}