(这是一个颜色会变化的呦)

#include <iostream>
using namespace std;
int b[][];
int n;
int m;
void qipan()
{
system("cls");
int k = ;
for (int k = ;k < n;++k)
{
for (int j = ;j < m;++j)
{
cout << " ---- ";
}
cout << endl;
for (int i = ;i < n;++i)
{
for (int j = ;j < m;++j)
{
if (b[i][j] < && b[i][j] >= ) cout << "| " << << b[i][j] << " |";
else if (b[i][j] == -) cout << "| " << "█" << " |";
else if (b[i][j] == -) cout << "|" << " ○ " << "|";
else cout << "| " << b[i][j] << " |"; k++;
} cout << endl;
for (int j = ;j < m;++j)
{
cout << " ---- ";
}
cout << endl;
}
}
}
void success()
{
long time;
for (;;)
{
system("color a");
for (time = ; time < ; time++);
system("color b");
for (time = ; time < ; time++);
system("color c");
for (time = ; time < ; time++);
system("color d");
for (time = ; time < ; time++);
system("color e");
for (time = ; time < ; time++);
system("color f");
for (time = ; time < ; time++);
system("color 0");
for (time = ; time < ; time++);
system("color 1");
for (time = ; time < ; time++);
system("color 2");
for (time = ; time < ; time++);
system("color 3");
for (time = ; time < ; time++);
system("color 4");
for (time = ; time < ; time++);
system("color 5");
for (time = ; time < ; time++);
system("color 6");
for (time = ; time < ; time++);
system("color 7");
for (time = ; time < ; time++);
system("color 8");
for (time = ; time < ; time++);
system("color 9");
}
}
int main()
{
cout << "请选择你们想要的棋盘大小(棋盘的面积请不要大于100)" << endl;
cout << "棋盘的长:(推荐长度为10)" << endl;
cin >> m;
cout << "棋盘的宽:(推荐长度为10)" << endl;
cin >> n;
for (int i = ;i < n;++i)
{
for (int j = ;j < m;++j)
{
b[i][j] = i * m + j;
}
}
qipan();
while ()
{
int x;
cout << "请玩家一输入:" << endl;
cin >> x;
if (x == )
{
cout << "玩家一使用系统外挂" << endl;
cout << "游戏结束" << endl;
cout << "玩家一获胜" << endl;
success();
return ;
}
for (int i = ;i < n;++i)
{
for (int j = ;j < m;++j)
{
if (b[i][j] == x) b[i][j] = -;
}
}
for (int i = ;i < n;++i)
{
for (int j = ;j < m - ;++j)
{
if ((b[i][j] == - && b[i][j + ] == - && b[i][j + ] == - && b[i][j + ] == - && b[i][j + ] == -)
|| (b[i][j] == - && b[i + ][j] == - && b[i + ][j] == - && b[i + ][j] == - && b[i + ][j] == -)
|| (b[i][j] == - && b[i + ][j + ] == - && b[i + ][j + ] == - && b[i + ][j + ] == - && b[i + ][j + ] == -))
{
cout << "游戏结束" << endl;
cout << "玩家一获胜" << endl;
success();
return ;
}
else if (i >= && (b[i][j] == - && b[i - ][j + ] == - && b[i - ][j + ] == - && b[i - ][j + ] == - && b[i - ][j + ] == -))
{
cout << "游戏结束" << endl;
cout << "玩家一获胜" << endl;
success();
return ;
}
}
}
qipan();
cout << "请玩家二输入:" << endl;
cin >> x;
if (x == )
{
cout << "玩家二使用系统外挂" << endl;
cout << "游戏结束" << endl;
cout << "玩家二获胜" << endl;
success();
return ;
}
for (int i = ;i < n;++i)
{
for (int j = ;j < m;++j)
{
if (b[i][j] == x) b[i][j] = -;
}
}
qipan();
for (int i = ;i < n;++i)
{
for (int j = ;j < m - ;++j)
{
if ((b[i][j] == - && b[i][j + ] == - && b[i][j + ] == - && b[i][j + ] == - && b[i][j + ] == -)
|| (b[i][j] == - && b[i + ][j] == - && b[i + ][j] == - && b[i + ][j] == - && b[i + ][j] == -)
|| (b[i][j] == - && b[i + ][j + ] == - && b[i + ][j + ] == - && b[i + ][j + ] == - && b[i + ][j + ] == -))
{
cout << "游戏结束" << endl;
cout << "玩家二获胜" << endl;
success();
return ;
}
else if (i >= && (b[i][j] == - && b[i - ][j + ] == - && b[i - ][j + ] == - && b[i - ][j + ] == - && b[i - ][j + ] == -))
{
cout << "游戏结束" << endl;
cout << "玩家二获胜" << endl;
success();
return ;
}
}
} }
}

最新文章

  1. jasmine test 页面测试工具
  2. entityframework
  3. static与并发
  4. 深入理解闭包系列第三篇——IIFE
  5. Android开发6:Service的使用(简单音乐播放器的实现)
  6. js二级导航下拉菜单
  7. Android Actitity的生命周期
  8. SQLServer:删除log文件和清空日志的方法
  9. 6/17 Sprint3
  10. 2.django笔记之缓存,session,cookie,ajax
  11. DateGradeView分页绑定
  12. Ubuntu通过源代码编译安装Octave 4.0
  13. Python学习笔记(一):列表和元组
  14. JavaScript树(一) 简介
  15. LeetCode之“动态规划”:Distinct Subsequences
  16. pandas列合并为一行
  17. 微信小程序(四) 模板的使用
  18. 廖雪峰Java8JUnit单元测试-2使用JUnit-2异常测试
  19. spring boot 注解
  20. SQL Server如何用触发器捕获DML操作的会话信息

热门文章

  1. 学习 bypass csp记录
  2. 大汇总 | 一文学会八篇经典CNN论文
  3. PHP入门之类型与运算符(一)
  4. Pycharm远程解释器SFTP开发和调试
  5. linux dig 命令使用
  6. JavaScript基础内容
  7. 你一个 F12 能秒我?
  8. Python for循环通过序列索引迭代
  9. PHP str_word_count() 函数
  10. 一本通 高手训练 1782 分层图 状压dp