编程论坛
注册
登录
编程论坛
→
C++教室
求c++写小游戏教程 谢谢!!!
Halloboy
发布于 2013-05-22 08:34, 880 次点击
我对编写游戏很感兴趣,不过我刚开始学,还请高手赐教。。。。。
9 回复
#2
邓士林
2013-05-22 13:59
共同学习进步
#3
a199121413
2013-05-22 14:09
同上
#4
Halloboy
2013-05-22 19:06
嗨,可是不知道怎样学才好,纠结呀!!!
#5
peach5460
2013-05-22 21:34
关注
#6
我有我梦
2013-05-29 08:41
游戏编程Very Cool!不过挺难的,求共同进步!!!
#7
qjyzpsy
2013-05-29 10:54
同求!
#8
TFrose
2013-06-01 09:31
我也是...
#9
蛋蛋的忧桑
2013-10-01 11:21
同求
#10
steve221
2018-02-27 20:11
新人做的,大神勿喷
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<string>
using namespace std;
int main(void)
{
int n,num,count=1,i=10,u=0;
string mystring;
cout<<"选择难度:"<<"easy,hard,very hard,impossible"<<"\n" ;
cin>>mystring;
if(mystring == "easy")
num=rand()%100;
if(mystring == "hard");
num=rand()%1000;
if(mystring == "very hard")
num=rand()%5000;
if(mystring == "impossible")
{
num=rand()%10000;
for(i=10;i>0;u++,i--)
{
cout<<"猜一个数"<<"\n"<<"还剩"<<i<<"次机会。"<<"\n";
cin>>n;
if(n == num)
break;
else if(n>num)
cout<<"大了!"<<"\n"<<"还剩"<<i<<"次机会!"<<"\n"<<"\n"<<"\n";
else
cout<<"小了!"<<"\n"<<"还剩"<<i<<"此机会!"<<"\n"<<"\n"<<"\n";
}
cout<<"挑战成功!!!"<<"用了"<<u<<"次机会!";
return 0;
}
do
{
cout<<"猜一个数:";
cin>>n;
if(n == num)
break;
else if(n>num)
cout<<"大了!"<<endl;
else
cout<<"小了!"<<endl;
count++;
}while(true);
cout<<"历经"<<count<<"次,猜对了。"<<endl;
return 0;
}
1