用C++可以做什么小游戏 一定不要太复杂的 我现在还没学完C++的 求大神指导 求源代码。谢谢。 5

我有更好的答案
邀请更新
2013-03-25 最佳答案

return true;/cout<<"x=" <zeroX+1 <
//, r = 3;
/ j++)
{
number[i][j] = n++;
}
}
number[LENGTH - 1][LENGTH - 1] = 0;
number[zeroY + 1][zeroX] = 0;
zeroY += 1;zeroX+1 <
return true, w = 1, e = 2;cout<<b <

#include <cstdlib>"<
void start();
bool up();
bool down();
bool left();
bool right();y="<
void show();
}
NumberM:;
return true; <<zeroY+1 <<endl;
move++;
}
else if(b % 5 == e)
{
left();
move++;
}
else if(b % 5 == r)
{
right();
move++;
}
else
{
q++;
w++;
e++;
r++;
}
}
}
while(win() || move <= 100);
for (int i = 0; i < LENGTH; i++)
{
for (int j = 0; j < LENGTH; j++)
{
if(number[i][j] == 0)
{
zeroX = j;
zeroY = i;
}
}
}
}
void NumberM::show()
{
for (int i = 0; i < LENGTH; i++)
{
for (int j = 0; j < LENGTH; j++)
{
if(number[i][j] == 0) cout << " " ;
else
{
if(number[i][j] < 10) cout << " ";
cout << " " << number[i][j] ;
}
}
cout << endl;
}
}
bool NumberM::win()
{
using std:cou

int n = 1;
for (int i = 0; i < LENGTH; i++)
{
for (int j = 0; j < LENGTH; j++)
{
if(i == LENGTH - 1 && j == LENGTH - 1) continue;
if(number[i][j] != n++) return false;
}
}
return true;
}

int main(int argc, char* argv[])
{
NumberM num;
num.start();
char moveGet;
bool isGet;
while(!num.win())
{
num.show();
do
{
cout << "左=h , 右=l , 上=k , 下=j " << endl;
cin >> moveGet ;
if(moveGet == 'k') num.up() ? isGet = true : isGet = false;
else if(moveGet == 'j') num.down() ? isGet = true : isGet = false;
else if(moveGet == 'h') num.left() ? isGet = true : isGet = false;
else if(moveGet == 'l') num.right() ? isGet = true : isGet = false;
}
while(!isGet);
}
num.show();
return 0;
}

很久以前写的,代码比较烂。。#include < "**************胜利**************" <endl;
return true;
}
bool NumberM:; <<zeroY+1 <<endl;/cout<<"b=" <:down()
{
if(zeroY == 0) return false;
number[zeroY][zeroX] = number[zeroY - 1][zeroX];
number[zeroY - 1][zeroX] = 0;<
}
bool NumberM;
}
void NumberM;< LENGTH:up()
{
if(zeroY == LENGTH - 1) return false;
int q = 0;
int zeroX;"::left()
{
if(zeroX == LENGTH - 1) return false;
number[zeroY][zeroX] = number[zeroY][zeroX + 1];
number[zeroY][zeroX + 1] = 0::start()
{
zeroX = LENGTH - 1;
}
bool NumberM; endl;
number[zeroY][zeroX] = number[zeroY + 1][zeroX];
zeroY -= 1;
/ <<zeroY+1 <<endl::right()
{
if(zeroX == 0) return false;
number[zeroY][zeroX] = number[zeroY][zeroX - 1];
number[zeroY][zeroX - 1] = 0;
zeroX += 1;
//cout<<"x=" < i++)
{
int b = randf(LENGTH * i - i);<, zeroY;
};
NumberM:;iostream> i <= 50;y="
zeroY = LENGTH - 1;
int move = 0;
#define LENGTH 3

int randf(int num) / i++)
{
for (int j = 0; j </生成随机数,小于num
{
srand((unsigned)time(NULL));
return rand() % num;
}
class NumberM
{
public:
NumberM();
~NumberM();
}
else if(b % 5 == w)
{
down();
#include <ctime> <<zeroX+1 <<"y=" < LENGTH;
bool win();
private:
int number[LENGTH][LENGTH];<<y="x="zeroX+1 <
for (int i = 0; i <<:NumberM()
{
int n = 1;
using namespace std;""<<<:~NumberM()
{
cout <
do
{
for (int i = 1;
char any;
cin >> any ;
}
bool NumberM:;endl;
if(b % 5 == q)
{
up();
move++;
zeroX -= 1;
/zeroY+1 </cout<<"x=" <<

其他回答

可以做文字游戏
代码满天飞
我只有自己写的,没注释的
自己写更好吧
南柯一梦之小 | 发布于2013-03-25
评论
用JAVE比较好吧。
丙丁朱雀火 | 发布于2013-03-25
评论

为您推荐:

×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消