论如何实现最强大脑黑白迭代(c++附代码)
最近看了最强大脑,对节目中的黑白迭代很感兴趣,就自己写了一个500多行的程序。燃鹅,只实现了一部分功能,还非常简陋。无奈之下,我只好从网上下载了一份代码,然后自己稍加修改就成了一份半改编的代码。
虽然代码不完全是我写的,但思路还是要有。
1.欢迎界面
2.规则界面
3.菜单
4.游戏界面
5.结束界面
这些大概需要几个功能。
1.随机取数
2.隐藏光标(游戏效果考虑)
3.移动光标
4.检查答案
结合以上这些,下面就是源代码
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <windows.h>
#include <conio.h>
using namespace std;
HANDLE handle;
COORD crd;
int rand_srand(int x);
void hide_cursor();
void gotoxy(int y, int x);
int c[][];
short question[][][] = {
/***level0***/
/***question 1***/
/***answer:1 1/1 10
answer:3 5
answer:5 3/5 5/5 6
answer:6 5/6 6
answer:10 1/10 10***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 2***/
/***answer:1 2/1 9
answer:2 1/2 10
answer:3 3/3 8
answer:8 3/8 8
answer:9 1/9 10
answer:10 2/10 9***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 3***/
/***answer:2 5/2 6
answer:5 2/5 5/5 6/5 9
answer:6 2/6 5/6 6/6 9
answer:9 5/9 6***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 4***/
/***answer:1 1/1 5/1 6/1 10
answer:2 2/2 9
answer:3 3/3 8
answer:4 4/4 7
answer:5 1/5 5/5 6/5 10
answer:6 1/6 5/6 6/6 10
answer:7 4/7 7
answer:8 3/8 8
answer:9 2/9 9
answer:10 1/10 5/10 6/10 10***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 5***/
/***answer:1 2/1 3
answer:2 1/2 2/2 3/2 4
answer:3 1/3 2/3 3/3 4/3 5
answer:4 2/4 3/4 4/4 5/4 6
answer:5 3/5 4/5 5/5 6/5 7
answer:6 4/6 5/6 6/6 7/6 8
answer:7 5/7 6/7 7/7 8/7 9
answer:8 6/8 7/8 8/8 9/8 10
answer:9 7/9 8/9 9/9 10
answer:10 8/10 9***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***level1***/
/***question 1***/
/***answer:1 1/1 4/1 7/1 10
answer:3 1/3 4/3 7/3 10
answer:5 1/5 4/5 7/5 10
answer:6 1/6 4/6 7/6 10
answer:8 1/8 4/8 7/8 10
answer:10 1/10 4/10 7/10 10***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 2***/
/***answer:1 2/1 5/1 6/1 9
answer:2 1/2 10
answer:5 1/5 10
answer:6 1/6 10
answer:9 1/9 10
answer:10 2/10 5/10 6/10 9***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 3***/
/***answer:1 3/1 8
answer:3 1/3 3/3 8/3 10
answer:5 5/5 6
answer:6 5/6 6
answer:8 1/8 3/8 8/8 10
answer:10 3/10 8
***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 4***/
/***answer:1 1/1 10
answer:3 3/3 5
answer:4 6
answer:5 3/5 5
answer:6 4/6 6/6 7
answer:7 6
answer:8 8
answer:10 1/10 10**/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 5***/
/***answer:1 5/1 6
answer:2 2/2 3/2 8/2 9
answer:3 2/3 3/3 8/3 9
answer:5 1/5 5/5 6/5 10
answer:6 1/6 5/6 6/6 10
answer:8 2/8 3/8 8/8 9
answer:9 2/9 3/9 8/9 9
answer:10 5/10 6***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***level2***/
/***question 1***/
/***answer:1 5/1 6
answer:3 4/3 7
answer:4 3/4 8
answer:5 5/5 6
answer:6 5/6 6
answer:7 3/7 8
answer:8 4/8 7
answer:10 5/10 6
answer:***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 2***/
/***answer:1 1/1 10
answer:2 2/2 9
answer:3 3/3 8
answer:5 5/5 6
answer:6 5/6 6
answer:8 3/8 8
answer:9 2/9 9
answer:10 1/10 10
***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 3***/
/***answer:2 2/2 3/2 5/2 6/2 8/2 9
answer:5 2/5 9
answer:6 2/6 9
answer:9 2/9 3/9 5/9 6/9 8/9 9***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 4***/
/***answer:2 5/2 6
answer:4 4/4 7
answer:5 2/5 5/5 6/5 9
answer:6 2/6 5/6 6/6 9
answer:7 4/7 7
answer:9 5/9 6***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 5***/
/***answer:2 2/2 3
answer:3 2/3 3/3 8
answer:4 5/4 6
answer:5 4/5 7
answer:6 4/6 7
answer:7 5/7 6
answer:8 3/8 8/8 9
answer:9 8/9 9***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***level3***/
/***question 1***/
/***answer:1 5/1 6
answer:2 3/2 8
answer:3 2/3 5/3 5/3 9
answer:5 1/5 3/5 8/5 10
answer:6 1/6 3/6 8/6 10
answer:8 2/8 5/8 6/8 9
answer:9 3/9 8
answer:10 5/10 6***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 2***/
/***answer:1 1/1 10
answer:2 2/2 9
answer:3 3/3 4/3 7/3 8
answer:4 3/4 8
answer:5 5/5 6
answer:6 5/6 6
answer:7 3/7 8
answer:8 3/8 4/8 7/8 8
answer:9 2/9 9
answer:10 1/10 10***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 3***/
/***answer:1 1/1 5/1 6/1 10
answer:2 2/2 5/2 6/2 9
answer:5 1/5 2/5 5/5 6/5 9/5 10
answer:6 1/6 2/6 5/6 6/6 9/6 10
answer:9 2/9 5/9 6/9 9
answer:10 1/10 5/10 6/10 10***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 4***/
/***answer:1 1/1 2/1 3/1 4/1 5/1 6/1 7/1 8/1 9/1 10
answer:2 1/2 10
answer:3 1/3 10
answer:4 1/4 4/4 7/4 10
answer:5 1/5 5/5 6/5 10
answer:6 1/6 5/6 6/6 10
answer:7 1/7 4/7 7/7 10
answer:8 1/8 10
answer:9 1/9 10
answer:10 1/10 2/10 3/10 4/10 5/10 6/10 7/10 8/10 9/10 10***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 5***/
/***answer:1 1/1 2/1 5/1 6/1 9/1 10
answer:2 1/2 2/2 5/2 6/2 9/2 10
answer:5 1/5 2/5 5/5 6/5 9/5 10
answer:6 1/6 2/6 5/6 6/6 9/6 10
answer:9 1/9 2/9 5/9 6/9 9/9 10
answer:10 1/10 2/10 5/10 6/10 9/10 10***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***level4***/
/***question 1***/
/***answer:1 1/1 5/1 6/1 10
answer:3 3/3 8
answer:4 4/4 7
answer:5 1/5 5/5 6/5 10
answer:6 1/6 5/6 6/6 10
answer:7 4/7 7
answer:8 3/8 8
answer:10 1/10 5/10 6/10 10
answer:***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 2***/
/***answer:1 2/1 5/1 6/1 9
answer:2 1/2 10
answer:3 3/3 8
answer:4 5/4 6
answer:5 1/5 4/5 5/5 6/5 7/5 10
answer:6 1/6 4/6 5/6 6/6 7/6 10
answer:7 5/7 6
answer:8 3/8 8
answer:9 1/9 10
answer:10 2/10 5/10 6/10 9***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 3***/
/***answer:1 4/1 7
answer:2 2/2 9
answer:3 5/3 6
answer:4 1/4 10
answer:5 3/5 5/5 6/5 8
answer:6 3/6 5/6 6/6 8
answer:7 1/7 10
answer:8 5/8 6
answer:9 2/9 9
answer:10 4/10 7***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 4***/
/***answer:1 5/1 6
answer:2 2/2 5/2 6/2 9
answer:4 4/4 7
answer:5 1/5 2/5 9/5 10
answer:6 1/6 2/6 9/6 10
answer:7 4/7 7
answer:9 2/9 5/9 6/9 9
answer:10 5/10 6***/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
/***question 5***/
/***answer:1 4/1 7
answer:2 2/2 9
answer:3 3/3 8
answer:4 1/4 4/4 6/4 10
answer:5 4/5 5/5 6/5 7
answer:6 4/6 5/6 6/6 7
answer:7 1/7 5/7 6/7 10
answer:8 8/8 3
answer:9 9/9 2
answer:10 4/10 7**/
{
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
{, , , , , , , , , , },
},
};
bool answer_group[][][] = {
/***level0***/
/***question1***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/***line10***/{, , , , , , , , , , },
},
/***question2***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question3***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question4***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question5***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***level1***/
/***question1***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question2***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question3***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question4***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question5***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***level2***/
/***question1***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question2***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question3***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question4***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question5***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***level3***/
/***question1***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question2***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question3***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question4***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question5***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***level4***/
/***question1***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question2***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question3***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question4***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
/***question5***/
{
/*** 0 1 2 3 4 5 6 7 8 9 10***/
/***line0***/{, , , , , , , , , , },
/***line1***/{, , , , , , , , , , },
/***line2***/{, , , , , , , , , , },
/***line3***/{, , , , , , , , , , },
/***line4***/{, , , , , , , , , , },
/***line5***/{, , , , , , , , , , },
/***line6***/{, , , , , , , , , , },
/***line7***/{, , , , , , , , , , },
/***line8***/{, , , , , , , , , , },
/***line9***/{, , , , , , , , , , },
/**line10***/{, , , , , , , , , , },
},
};
/***定义基础变量***/
int question_number;
int hide_question_time;
short level;
int x, y;
int steps; struct xystep{
int Cx, Cy;
};
xystep xysteps[];
void welcome(){
/***设置输出框大小***/
system("mode con cols=54 lines=13"); /***cout << "WELCOME TO \"BLACK AND WHITE ITERATION\"";***/
gotoxy(,);
cout << "W";Sleep();
cout << "E";Sleep();
cout << "L";Sleep();
cout << "C";Sleep();
cout << "O";Sleep();
cout << "M";Sleep();
cout << "E";Sleep();
cout << " ";Sleep();
cout << "T";Sleep();
cout << "O";Sleep();
cout << " ";Sleep();
cout << "\"";Sleep();
cout << "B";Sleep();
cout << "L";Sleep();
cout << "A";Sleep();
cout << "C";Sleep();
cout << "K";Sleep();
cout << " ";Sleep();
cout << "A";Sleep();
cout << "N";Sleep();
cout << "D";Sleep();
cout << " ";Sleep();
cout << "W";Sleep();
cout << "H";Sleep();
cout << "I";Sleep();
cout << "T";Sleep();
cout << "E";Sleep();
cout << " ";Sleep();
cout << "I";Sleep();
cout << "T";Sleep();
cout << "E";Sleep();
cout << "R";Sleep();
cout << "A";Sleep();
cout << "T";Sleep();
cout << "I";Sleep();
cout << "O";Sleep();
cout << "N";Sleep();
cout << "\"";Sleep(); /***cout << "press \"Enter\" to continue"***/
gotoxy(, );
cout << "p";Sleep();
cout << "r";Sleep();
cout << "e";Sleep();
cout << "s";Sleep();
cout << "s";Sleep();
cout << " ";Sleep();
cout << "\"";Sleep();
cout << "E";Sleep();
cout << "n";Sleep();
cout << "t";Sleep();
cout << "e";Sleep();
cout << "r";Sleep();
cout << "\"";Sleep();
cout << " ";Sleep();
cout << "t";Sleep();
cout << "o";Sleep();
cout << " ";Sleep();
cout << "c";Sleep();
cout << "o";Sleep();
cout << "n";Sleep();
cout << "t";Sleep();
cout << "i";Sleep();
cout << "n";Sleep();
cout << "u";Sleep();
cout << "e";Sleep();
char ch = ;
do{
ch = _getch();
}while (ch != VK_RETURN);
}
void thank(){
/***设置输出框大小***/
system("mode con cols=54 lines=13"); /***cout << "THANK YOU FOR PLAYING";***/
gotoxy(, );
cout << "T";Sleep();
cout << "H";Sleep();
cout << "A";Sleep();
cout << "N";Sleep();
cout << "K";Sleep();
cout << " ";Sleep();
cout << "Y";Sleep();
cout << "O";Sleep();
cout << "U";Sleep();
cout << " ";Sleep();
cout << "F";Sleep();
cout << "O";Sleep();
cout << "R";Sleep();
cout << " ";Sleep();
cout << "P";Sleep();
cout << "L";Sleep();
cout << "A";Sleep();
cout << "Y";Sleep();
cout << "I";Sleep();
cout << "N";Sleep();
cout << "G";Sleep(); /***cout << "press \"Enter\" to continue"***/
gotoxy(, );
cout << "p";Sleep();
cout << "r";Sleep();
cout << "e";Sleep();
cout << "s";Sleep();
cout << "s";Sleep();
cout << " ";Sleep();
cout << "\"";Sleep();
cout << "E";Sleep();
cout << "n";Sleep();
cout << "t";Sleep();
cout << "e";Sleep();
cout << "r";Sleep();
cout << "\"";Sleep();
cout << " ";Sleep();
cout << "t";Sleep();
cout << "o";Sleep();
cout << " ";Sleep();
cout << "c";Sleep();
cout << "o";Sleep();
cout << "n";Sleep();
cout << "t";Sleep();
cout << "i";Sleep();
cout << "n";Sleep();
cout << "u";Sleep();
cout << "e";Sleep();
char ch = ;
do{
ch = _getch();
}while (ch != VK_RETURN);
}
int rand_srand(int x){
srand((unsigned)time(NULL));
return rand() % x;
}
void hide_cursor(){
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord;
CONSOLE_CURSOR_INFO cursor_info={,};
SetConsoleCursorInfo(hout, &cursor_info);
}
void gotoxy(int y, int x) {
int xx = 0x0b;
HANDLE hOutput;
COORD loc;
loc.X = x;
loc.Y = y;
hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOutput, loc);
return;
}
void print_equirement(){
/***输出顶部***/
gotoxy(, );
cout << "────────────────────── equirement───────────────────────" << endl;
/***输出所有equirement***/
gotoxy(, );
cout << " 开始游戏请输出“0 0”" << endl;
gotoxy(, );
cout << " 检查答案请输出“11 11”" << endl;
gotoxy(, );
cout << " 重置答案请输出“12 12”" << endl;
gotoxy(, );
cout << " 换一个问题请输出“13 13”" << endl;
gotoxy(, );
cout << " 隐藏问题请输出“14 14”" << endl;
gotoxy(, );
cout << " 撤销答案请输出“15 15”" << endl;
gotoxy(, );
cout << " 看答案请输出“16 16”" << endl;
gotoxy(, );
cout << "───────────────────── answer place─────────────────────" << endl;
}
void print_your_answer(){
for(int i = ;i <= ;i++){
gotoxy( + i, );
for(int j = ;j <= ;j++){
if(c[i][j] == )
cout << "■";
if(c[i][j] == )
cout << "□";
}
}
}
void print_question(int l){
for(int i = ;i <= ;i++){
gotoxy( + i, );
for(int j = ;j <= ;j++){
if(question[l][i][j] == )
cout << "■";
if(question[l][i][j] == )
cout << "□";
}
}
}
void print_boundary(){
/***输出左上角***/
gotoxy(, );
cout << "┌";
/***输出左边***/
for(int i = ;i <= ;i++){
gotoxy(i, );
if(i != && i != )
cout << "│";
else
cout << "┝";
}
/***输出左下角***/
gotoxy(, );
cout << "└"; /***输出右上角***/
gotoxy(, );
cout << "┐";
/***输出右边***/
for(int i = ;i <= ;i++){
gotoxy(i, );
if(i != && i != )
cout << "│";
else
cout << "┤";
}
/***输出右下角***/
gotoxy(, );
cout << "┘"; /***输出caution行***/
gotoxy(, );
cout << "──────────────────────── caution───────────────────────";
/***输出最下面***/
gotoxy(, );
for(int i = ;i <= ;i++)
cout << "─";
}
void print_xyplaces(){
gotoxy(, );
cout << "row:";
gotoxy(, );
cout << "column:";
}
void print_all(int l){
print_equirement();
print_boundary();
print_xyplaces();
gotoxy(, );
cout << " question" << endl;
print_question(l);
cout << endl;
gotoxy(, );
cout << " your answer" << endl;
print_your_answer();
}
void print_finish_reply(){
for(int i = ;i <= ;i++){
gotoxy( + i, );
cout << " ";
} /***输出边框***/
gotoxy(, );
cout << "┌─────────────────────────┐";
for(int i = ;i <= ;i++){
gotoxy( + i, );
cout << "│";
gotoxy( + i, );
cout << "│";
}
gotoxy(, );
cout << "└─────────────────────────┘";
}
short ShowMenu() {
system("cls");
//返回值显示用户所选难度级别
gotoxy(, );
cout << "你想要玩什么级别的关卡?"; /***输出顶部***/
gotoxy(, );
cout << "┌──────────────────────────────────────────┐";
/***输出左侧***/
for(int i = ;i <= ;i++){
gotoxy(i, );
cout << "│";
}
/***输出右侧***/
for(int i = ;i <= ;i++){
gotoxy(i, );
cout << "│";
}
/***输出隔层***/
gotoxy(, );
cout << "┝──────────────────────────────────────────┤";
/***输出选择规则***/
gotoxy(, );
cout << "左右键选择";
/***输出底部***/
gotoxy(, );
cout << "└──────────────────────────────────────────┘"; /***定义result和输入的VK变量***/
short result = ;
char ch = ; do {
/***左方向键***/
if (ch == )
result = (result + ) % ; /***右方向键***/
if (ch == )
result = (result + ) % ; /***被选中时绿底黑字,未被选中时黑底白字***/
/***容易***/
gotoxy(, );
if (result == ) SetConsoleTextAttribute(handle, BACKGROUND_GREEN);
else SetConsoleTextAttribute(handle, FOREGROUND_GREEN| FOREGROUND_BLUE| FOREGROUND_RED);
cout << "容易"; /***简单***/
gotoxy(, );
if (result == ) SetConsoleTextAttribute(handle, BACKGROUND_GREEN);
else SetConsoleTextAttribute(handle, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
cout << "简单"; /***中等***/
gotoxy(, );
if (result == ) SetConsoleTextAttribute(handle, BACKGROUND_GREEN);
else SetConsoleTextAttribute(handle, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
cout << "中等"; /***困难***/
gotoxy(, );
if (result == ) SetConsoleTextAttribute(handle, BACKGROUND_GREEN);
else SetConsoleTextAttribute(handle, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
cout << "困难"; /***炼狱***/
gotoxy(, );
if (result == ) SetConsoleTextAttribute(handle, BACKGROUND_GREEN);
else SetConsoleTextAttribute(handle, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
cout << "地狱"; ch = _getch();
if (ch == )
ch = _getch();
} while (ch != VK_RETURN);/***只有按下回车键,结束循环***/ /***恢复成默认文字及背景色***/
SetConsoleTextAttribute(handle, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
system("cls");
return result;
}
void show_ans(int l){
/***将提示框的背景清空***/
for(int i = ;i <= ;i++){
gotoxy( + i, );
cout << " ";
} /***输出提示框***/
gotoxy(, );
/***输出顶部***/
cout << "┌─────────────────────────┐";
gotoxy(, );
/***输出底部***/
cout << "└─────────────────────────┘";
/***输出两边***/
for(int i = ;i <= ;i++){
gotoxy( + i, );
cout << "│";
gotoxy( + i, );
cout << "│";
} /***输出答案部分***/
for(int i = ;i <= ;i++){
gotoxy( + i, );
cout << "row" << i << ":";
for(int j = ;j <= ;j++)
if(answer_group[l][i][j] == )
cout << j << " ";
} }
void rule(){
/***设置输出框大小***/
system("mode con cols=54 lines=13"); /***输出规则***/
gotoxy(, );
cout << " input the row and column each time";
gotoxy(, );
cout << " This position and the top, bottom, left and right";
gotoxy(, );
cout << " of this position will change to opposite color";
gotoxy(, );
cout << " Finally, we need to reach the image on the left";
gotoxy(, );
cout << " press \"Enter\" to continue"; /***输出外框***/
/***输出顶部***/
gotoxy(, );
cout << " ┌────────────────────── rule──────────────────────┐";
/***输出底部***/
gotoxy(, );
cout << " └─────────────────────────────────────────────────┘";
/***输出两侧***/
for(int i = ;i <= ;i++){
gotoxy( + i, );
cout << " │";
gotoxy( + i, );
cout << "│";
} /***判断是否敲击回车***/
char ch = ;
do{
ch = _getch();
}while (ch != VK_RETURN);
}
void hide_question(){
/***隐藏问题***/
for(int i = ;i <= ;i++){
gotoxy(i + , );
cout << " ";
} /***输出提示框***/
gotoxy(, );
cout << "The question";
gotoxy(, );
cout << "is hide!";
gotoxy(, );
cout << "┌─────────────┐";
for(int i = ;i <= ;i++){
gotoxy( + i, );
cout << "│";
gotoxy( + i, );
cout << "│";
}
gotoxy(, );
cout << "└─────────────┘";
}
void reset(int l){
/***棋盘数值归零***/
for(int i = ;i <= l;i++)
for(int j = ;j <= l;j++)
c[i][j] = ;
}
bool chk(int l){
/***逐个判断是否正确***/
for(int i = ;i <= ;i++)
for(int j = ;j <= ;j++)
if(c[i][j] != question[l][i][j])
return false;
return true;
}
void revoke(int sstep){
c[xysteps[sstep].Cx][xysteps[sstep].Cy] = (c[xysteps[sstep].Cx][xysteps[sstep].Cy] + ) % ;
c[xysteps[sstep].Cx + ][xysteps[sstep].Cy] = (c[xysteps[sstep].Cx + ][xysteps[sstep].Cy] + ) % ;
c[xysteps[sstep].Cx - ][xysteps[sstep].Cy] = (c[xysteps[sstep].Cx - ][xysteps[sstep].Cy] + ) % ;
c[xysteps[sstep].Cx][xysteps[sstep].Cy + ] = (c[xysteps[sstep].Cx][xysteps[sstep].Cy + ] + ) % ;
c[xysteps[sstep].Cx][xysteps[sstep].Cy - ] = (c[xysteps[sstep].Cx][xysteps[sstep].Cy - ] + ) % ;
}
int main(){
/***隐藏鼠标光标***/
hide_cursor(); /***输出欢迎***/
welcome();
system("cls");
Sleep(); /***输出规则***/
rule();
system("cls");
Sleep(); /***设置menu输出框的大小***/
GAME_START:
system("mode con cols=54 lines=13");
handle = GetStdHandle(STD_OUTPUT_HANDLE); /***确定难度***/
level = ShowMenu(); /***设置game输出框的大小***/
system("mode con cols=59 lines=28");
question_number = rand_srand() + level * ;
print_all(question_number); /***多次输入行列数***/
while(true){
/***输入行列数***/
gotoxy(, );
cin >> x;
if(hide_question_time == ){
gotoxy(, );
cin >> y;
}
else if(hide_question_time == ){
gotoxy(, );
cin >> y;
}
/***记录每一步和步数***/
if(x >= && x <= && y >= && y <= ){
steps++;
xysteps[steps].Cx = x;
xysteps[steps].Cy = y;
}
system("cls"); /***判断放弃***/
if(x == && y == ){
int gi;
print_all(question_number);
/***输出caution***/
gotoxy(, );
cout << " Do you wanna give up?" << endl;
gotoxy(, );
cout << " (answer '1' if you want)";
gotoxy(, );
cout << " (answer '0' if you don't want)"; /***询问reply***/
gotoxy(, );
cout << "reply:";
gotoxy(, );
cout << " ";
gotoxy(, );
cin >> gi; /***判断是否确定放弃***/
if(gi == )
break; /***盖住reply***/
gotoxy(, );
cout << " ";
gotoxy(, );
cout << " ";
} /***判断检查***/
if(x == + && y == + )
/***正确***/
if(chk(question_number)){
print_all(question_number);
/***输出caution***/
gotoxy(, );
cout << " congratulation(press \"Enter\" to continue)" << endl << endl;
char ch = ;
do{
ch = _getch();
}while (ch != VK_RETURN); /***判断是否再来一局***/
print_finish_reply();
int rep;
/***输出caution***/
gotoxy(, );
cout << " Do you wanna play again?";
gotoxy(, );
cout << " press '1' if you want. ";
gotoxy(, );
cout << " reply:";
/***输入reply***/
gotoxy(, );
cin >> rep;
/***判断是否为重新开始游戏***/
if(rep == ){
reset();
goto GAME_START;
}
else{
gotoxy(, );
thank();
system("cls");
return ;
}
}
/***错误***/
else{
print_all(question_number);
/***输出caution***/
gotoxy(, );
cout << " Your answer is not correct,please continue!" << endl;
} /***重置答案***/
if(x == + && y == + ){
/***重置棋盘***/
reset(); /***输出caution***/
gotoxy(, );
cout << " You answer is reset!" << endl; /***部署清零***/
steps = ;
} /***重置问题***/
if(x == + && y == + ){
question_number = rand_srand() + level * ;
/***输出caution***/
gotoxy(, );
cout << " The quetion is change!" << endl;
} /***判断输入是否为改变棋盘状态***/
if(x == + && y == + ){
hide_question_time = (hide_question_time + ) % ;
if(hide_question_time == ){
/***输出caution***/
gotoxy(, );
cout << " The question is hide!";
gotoxy(, );
cout << " Please contniue to solve the problem!";
gotoxy(, );
cout << " type '14 14' again to show the question!";
}
if(hide_question_time == ){
gotoxy(, );
cout << " The problem display!";
}
} /***判断是否撤销上一步***/
if(x == + && y == + ){
/***判断是否为第一步***/
if(steps != ){
revoke(steps);
steps--;
print_all(question_number);
gotoxy(, );
cout << " The previous step has been revoke!";
}
else if (steps == ){
gotoxy(, );
cout << " you can't revoke any step!";
}
} /***判断是否为观察答案案***/
if(x == + && y == + ){
/***输出全部***/
print_all(question_number);
gotoxy(, );
/***输出caution***/
cout << " press 'Enter' to continue!";
/***显示答案***/
show_ans(question_number);
/***判断是否回车***/
char ch = ;
do{
ch = _getch();
}while (ch != VK_RETURN);
system("cls");
} /***判断是否合法输入***/
if(x > || x < || y > || y < || (x >= && y <= ) || (x <= && y >= )){
/***输出caution***/
gotoxy(, );
cout << " Please input the correct number!" << endl;
print_all(question_number);
if(hide_question_time == )
hide_question();
continue;
} /***改变颜色***/
if(x >= && x <= && y >= && y <= ){
c[x][y] = (c[x][y] + ) % ;
c[x + ][y] = (c[x + ][y] + ) % ;
c[x - ][y] = (c[x - ][y] + ) % ;
c[x][y + ] = (c[x][y + ] + ) % ;
c[x][y - ] = (c[x][y - ] + ) % ;
}
print_all(question_number); /***如果状态是隐藏,隐藏问题棋盘***/
if(hide_question_time == )
hide_question();
}
return ;
}
求给个赞吧,敲代码很辛苦的。
论如何实现最强大脑黑白迭代(c++附代码)的更多相关文章
- C语言 迭代部分的代码编写
C语言代码学习 迭代部分 迭代要用到函数部分的知识,一开始我写了计算n!的计算,代码和运行结果如下: 结果只能单一的计算出整数内的值,如果输入负值则结果为返回值1,显然是不对的,根据查书学习以后,知道 ...
- day11-Python运维开发基础(迭代器与可迭代对象、高阶函数)
1. 迭代器与可迭代对象 # ### 迭代器 """ 迭代器: 能被next方法调用,并且不断返回下一个值的对象,是迭代器(对象) 特征:迭代器会生成惰性序列,它通过计算 ...
- 迭代dict的key和value
我们了解了如何迭代 dict 的key和value,那么,在一个 for 循环中,能否同时迭代 key和value?答案是肯定的. 首先,我们看看 dict 对象的 items() 方法返回的值: & ...
- HDU.2899.Strange fuction(牛顿迭代)
题目链接 \(Description\) 求函数\(F(x)=6\times x^7+8\times x^6+7\times x^3+5\times x^2-y\times x\)在\(x\in \l ...
- HDU 5297 Y sequence 容斥 迭代
Y sequence 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5297 Description Yellowstar likes integer ...
- 使用 yield生成迭代对象函数
https://www.cnblogs.com/python-life/articles/4549996.html https://www.liaoxuefeng.com/wiki/001431608 ...
- python语言实现阶乘的两种方法---递归和迭代
阶乘的递归实现,代码如下: def factorial(n): if n==1: return 1 else: return n*factorial(n-1) number = int(input(& ...
- Python语法速查: 6. 循环与迭代
返回目录 (1)while循环与for循环 while仅能用于普通循环,而for除了可以做循环外,还可以遍历序列.集合.字典.迭代器等. 需要注意的是,在类似:for i in somelist: 的 ...
- python--基础知识点梳理(一)数据类型、迭代生成装饰器、函数
可变数据类型和不可变数据类型有哪些? # 可变数据类型:列表.字典.集合 # 不可变数据类型:数字.元祖.字符串 常见数据结构 # 栈(stack)--先进后出. 队列(queue)-先进先出.链表( ...
随机推荐
- Go Pentester - HTTP CLIENTS(5)
Parsing Document Metadata with Bing Scaping Set up the environment - install goquery package. https: ...
- P4017 最大食物链计数(洛谷)
老师开始帮我们查漏补缺啦!我们的老师这两天给了我们一些我们没怎么学的函数和算法,比如STL的函数和拓扑排序之类的,这个题就是讲拓扑排序的. 先看题板: 题目背景 你知道食物链吗?Delia 生物考试的 ...
- 关于Object.defineProperty
讲解大致会根据下图展开 本文部分参考了书籍<你不知道的javascript>上卷 对象的定义与赋值 经常使用的定义与赋值方法obj.prop =value或者obj['prop'] ...
- eclipse GIT本地库分支操作
git分支是一个重要的知识点,平时我们开发主要结合eclipse,idea来操作,今天这贴主要以eclipse来操作git本地库分支,主要内容包括新建分支,切换分支,合并分支,冲突解决,重命名分支,删 ...
- jq转盘抽奖
之前项目的时候要写一个抽奖,自己写了以后就记录一下. 先是html <div class="turntable_zhan"> <img class="y ...
- Java基础之(IO流)
简介: 流是一组有顺序的,有起点和终点的字节集合,是对数据传输的总称或抽象.即数据在两设备间的传输称为流,流的本质是数据传输,根据数据传输特性将流抽象为各种类,方便更直观的进行数据操作. 一.File ...
- Springboot(一)springboot简介与入门程序
一.springboot简介: 对spring框架盛行了多年的java方向开发人员来说,每个人java开发已经把spring框架当做开发中不可或缺的一部分. 之前传统的模式都是以application ...
- C#中子类对基类方法的继承、重写和隐藏
提起子类.基类和方法继承这些概念,肯定大家都非常熟悉.毕竟,作为一门支持OOP的语言,掌握子类.基类是学习C#的基础.不过,这些概念虽然简单,但是也有一些初学者可能会遇到的坑,我们一起看看吧. 子 ...
- Python File writelines() 方法
概述 writelines() 方法用于向文件中写入一序列的字符串.高佣联盟 www.cgewang.com 这一序列字符串可以是由迭代对象产生的,如一个字符串列表. 换行需要制定换行符 \n. 语法 ...
- Prism.Interactivity 和 Prism.Modularity 介绍
Prism.Interactivity: 主要用来截取View即界面的一些处理,而这些功能通过vm 不好实现,只能用 CommandBehaviorBase 来截取处理,特别是在处理界面异常很有用. ...