#include <iostream>
#include <cstring>
#include <windows.h>
#include <cstdlib>
#include <string>
#define SIZE 103
int a[SIZE][SIZE], b[SIZE][SIZE], n = 5, st, hh = 3, sc = 0, la;
bool flag;
using namespace std;
void dfs(int x, int y) // 消除
{
int c;
if (a[x][y] == 0)
{
return;
}
if (((x > n) || (x < 1)) || ((y > n) || (y < 1)))
{
return;
}
c = a[x][y];
a[x][y] = 0;
sc += c;
la += c;
if ((x > 1) && (a[x-1][y] == c))
{
flag = true;
dfs(x - 1, y);
}
if ((x < n) && (a[x+1][y] == c))
{
flag = true;
dfs(x + 1, y);
}
if ((y > 1) && (a[x][y-1] == c))
{
flag = true;
dfs(x, y - 1);
}
if ((y < n) && (a[x][y+1] == c))
{
flag = true;
dfs(x, y + 1);
}
return;
}
int main(int argc, char** argv)
{
int m, i, j, k, x = 1, y = 1, cc;
srand(cc);
a[n][n] = 3;
while (true) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
【游戏】合到十源码
最新推荐文章于 2022-11-11 21:56:48 发布
本文提供了一个C++实现的合到十游戏的完整源代码,包括游戏逻辑和用户交互。通过深度优先搜索(DFS)消除相同数字,并进行随机填充,更新游戏步骤、最高分和当前得分。

最低0.47元/天 解锁文章
3787

被折叠的 条评论
为什么被折叠?



