扫雷
来源:互联网 发布:淘宝降价通知 编辑:程序博客网 时间:2024/06/11 01:42
#include "stdafx.h"#include#include #include int main(void){//扫雷 10行10列 int map[10][10] = { 0 };int row = 0, col = 0;srand(time(0));int count = 10;do{row = rand() % 10;col = rand() % 10;if (!map[row][col]){map[row][col] = -1;count--;}} while (count>0);for (row = 0; row <= 9; row++){for (col = 0; col <= 9; col++){if (!map[row][col]){printf("0");}else if (map[row][col] == -1){printf("X");}}printf("\n");}printf("填入数字\n");//周围的 int zhouwei[3][3] = { 0 };//存储每个位置周围有几个雷int map_number[10][10] = { 0 };int number = 0;for (row = 0; row <= 9; row++){for (col = 0; col <= 9; col++){if (row - 1 == -1){for (int i = 0; i<3; i++){zhouwei[0][i] = -1;}}if (row + 1 == 10){for (int i = 0; i<3; i++){zhouwei[2][i] = -1;}}if (col - 1 == -1){for (int j = 0; j<3; j++){zhouwei[j][0] = -1;}}if (col + 1 == 10){for (int j = 0; j<3; j++){zhouwei[j][2] = -1;}}zhouwei[1][1] = -1;for (int i = 0; i<3; i++){for (int j = 0; j<3; j++){if (zhouwei[i][j] == 0){if (map[row + i - 1][col + j - 1] == -1){number++;}}}}map_number[row][col] = number;if (map[row][col] == -1){printf("X");}else{printf("%d", number);}number = 0;for (int i = 0; i<3; i++){for (int j = 0; j<3; j++){zhouwei[i][j] = 0;}}}printf("\n");}getchar();return 0;}
0 0
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 扫雷
- 基于Python的四通道图像融合(二)
- window操作系统
- 大型分布式网站相关概念及优化
- 面向对象的基础知识:类Class,对象(Object),实例(Instance)
- springMVC报错java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
- 扫雷
- fork结合逻辑与或
- Vue基本用法
- 微信小程序开发常见FAQ
- ajax form表单提交,serialize和formData的区别
- Ubuntu下Java环境变量的配置
- 4.20学习-关于hping3的安装
- Windows bat脚本之for循环之帮助
- db2sql报错代码大全