新微赢技术网

标题: 怎么实现程序得窗口化? [打印本页]

作者: ㄣ紸縡のoァ    时间: 2009-11-3 01:01
标题: 怎么实现程序得窗口化?
首先,我是个超级菜鸟.现在编得程序一般都只是一个DOS窗口.

比如下面这个猜数字得游戏只是DOS窗口.但我想设计成好像扫雷那样得有界面得程序需要怎么搞啊?
以下代码由本论坛得网友提供.
#include<iostream>
#include<cstdlib>
using namespace std;
int menu();
void play();
int main()
{
int choice,operate,magic;
do
{
operate=menu();
switch (operate)
{
case 1:play();break;
case 2:break;
case 3:cout<<"Goodbye!"<<endl;break;
}
}while (operate != 3);
return 0;
}

// menu fuction...
int menu()
{
int choice;
cout<<"1.Get a new magic number."<<endl;
cout<<"2.Play now."<<endl;
cout<<"3.Quit."<<endl;
cout<<"Enter your choice:";
cin>>choice;
return choice;
}
//play fuction...
void play()
{
int i,magic,guess;
magic = rand();
magic = magic%10;
for (i=1;i<=3;i++)
{
cout<<"Guess :";
cin>>guess;
if (guess==magic)
{cout<<"**RIGHT**"<<endl<<endl<<endl;break;}
else if (guess>magic)
cout<<"It's too high."<<endl;
else cout<<"It's too low."<<endl;
}
if (i==4)
{cout<<endl<<"**Your chance have losted out.**"<<endl<<"End game this time.";
cout<<endl<<"The magicNum is "<<magic;
cout<<endl<<"Come on again?"<<endl<<endl<<endl;}

}
作者: 简单快乐    时间: 2009-11-3 01:01
要MFC的吧……




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2