• Bio

    老师,有bug,不信你看用户名^

    #include<bits/stdc++.h>
    #include<ctime>
    #include<cstdlib>
    #include<windows.h>
    #include<conio.h>
    #include<ole2.h>
    using namespace std;
    int getRand(int min, int max) {
    	return (rand() % (max - min + 1)) + min;
    }//伪随机数
    HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coord;
    void ClearW() {
    	HANDLE hOut;
    	COORD Position;
    	hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    	Position.X = 0;
    	Position.Y = 0;
    	SetConsoleCursorPosition(hOut, Position);
    }//清屏
    void HideCursor() {
    	CONSOLE_CURSOR_INFO cursor_info = {1, 0};
    	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
    }//隐藏光标
    int high,weight;
    char game_map[505][505], game_answer[505][505];
    bool highlight[505][505];
    int mine_num,mine_num1, chose_x=1,chose_y=1,chose_nx=1,chose_ny=1,mine_num_true;
    bool gameover=0;
    int game_time;
    int tips=3;
    int out(int x) {
    	if(x==1) {
    		cout << "\n\n\n\n\t\t\t\t\t    《 开始游戏 》" << endl;
    		cout << "\n\n\n\n\t\t\t\t\t         难度 " << endl;
    	} else if(x==0) {
    		cout << "\n\n\n\n\t\t\t\t\t       开始游戏 " << endl;
    		cout << "\n\n\n\n\t\t\t\t\t     《  难度  》 " << endl;
    	} else if(x==2) {
    		cout << "\n\n\n\n\t\t\t\t\t     《  简单  》     10%" << endl;
    		cout << "\n\n\n\n\t\t\t\t\t         普通" << endl;
    		cout << "\n\n\n\n\t\t\t\t\t         困难    " << endl;
    	} else if(x==3) {
    		cout << "\n\n\n\n\t\t\t\t\t         简单  " << endl;
    		cout << "\n\n\n\n\t\t\t\t\t     《  普通  》    30%" << endl;
    		cout << "\n\n\n\n\t\t\t\t\t         困难    " << endl;
    	} else if(x==4) {
    		cout << "\n\n\n\n\t\t\t\t\t         简单  " << endl;
    		cout << "\n\n\n\n\t\t\t\t\t         普通" << endl;
    		cout << "\n\n\n\n\t\t\t\t\t     《  困难  》   50%" << endl;
    	} else if(x==10) {
    		HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    		SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    		cout << "# ";
    		SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
    		cout << "为未探索的土地\n" ;
    		SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    		cout << "* ";
    		SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
    		cout << "为地雷\n";
    		SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    		SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    		cout << "@ ";
    		SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
    		cout << "为九宫格消除道具" << endl;
    		SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    		cout << "带数字的格子 ";
    		SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
    		cout << "为它周围\n" ;
    		cout << "8个格子内地雷的数量\n" ;
    		cout << "Space 标记,Enter 确认,/ 取消,t排查(为*就标记,否则翻开)\n";
    		SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    		cout << "U ";
    		SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
    		cout << "代表选中,上下左右键 移动\n";
    		SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    		cout << "\n\n\t\t\t\t\t欢迎来到扫雷的世界,尽情玩耍吧!" << endl;
    		cout << "\t\t\t\tWelcome to the world of minesweeper and have fun!";
    		cout << "\n\t\t\t\t\t\t按任意键继续";
    		char gamestrat = getch();
    	} else if(x==11) {
    		for (int i = 1; i <= (120 - weight) / 2 - 1; i++) cout << " ";
    	} else if(x==12) {
    		HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    		out(11);
    		SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    		SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    		cout  << "mine_number=" << mine_num << " "<<"tip="<<tips<<endl;
    		cout << " ";
    		out(11);
    		for (int i = 1; i <= weight; i++) cout << "-";
    		cout <<"\n";
    		for (int i = 1; i <= high; i++) {
    			out(11);
    			cout << "|";
    			for (int j = 1; j <= weight; j++) {
    				if (i==chose_nx&&j==chose_ny) {
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    					printf("%c", 'U');
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    				} else if(highlight[i][j]==1) {
    					SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
    					printf("%c", '^');
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    				} else if (game_map[i][j] == '@') {
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN |  FOREGROUND_INTENSITY);
    					printf("%c", game_map[i][j]);
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    				} else if (game_map[i][j] == '#') {
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    					printf("%c", game_map[i][j]);
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    				}  else if (game_answer[i][j] == '*') {
    					SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    					printf("%c", game_answer[i][j]);
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    				} else if (game_map[i][j] == '0') printf("%c", ' ');
    				else printf("%c", game_map[i][j]);
    			}
    			cout << "|" << endl;
    		}
    		cout << " ";
    		out(11);
    		for (int i = 1; i <= weight; i++) cout << "-";
    	} else if(x==13) {
    		HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    		out(11);
    		SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    		SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    		cout  << "mine_number=" << mine_num << " "<<"tip="<<tips<<endl;
    		cout << " ";
    		out(11);
    		for (int i = 1; i <= weight; i++) cout << "-";
    		cout <<"\n";
    		for (int i = 1; i <= high; i++) {
    			out(11);
    			cout << "|";
    			for (int j = 1; j <= weight; j++) {
    				if(highlight[i][j]==1&&game_answer[i][j] == '*') {
    					SetConsoleTextAttribute(hConsole,  FOREGROUND_RED | FOREGROUND_INTENSITY);
    					printf("%c", game_answer[i][j]);
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    				} else if (game_answer[i][j] == '#') {
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN |  FOREGROUND_INTENSITY);
    					printf("%c", game_answer[i][j]);
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    				} else if (game_answer[i][j] == '@') {
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    					printf("%c", game_answer[i][j]);
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    				} else if (game_answer[i][j] == '*') {
    					SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    					printf("%c", game_answer[i][j]);
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    				} else if (game_answer[i][j] == '0') printf("%c", ' ');
    				else printf("%c", game_answer[i][j]);
    				Sleep(1);
    			}
    			cout << "|" << endl;
    		}
    		cout << " ";
    		out(11);
    		for (int i = 1; i <= weight; i++) cout << "-";
    	}
    }//输出
    int outline(int x) {
    	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    	out(11);
    	if(x!=0) {
    		cout << "|";
    	}
    	for (int j = 1; j <= weight; j++) {
    		if (x==chose_nx&&j==chose_ny) {
    			SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    			printf("%c", 'U');
    			SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    		} else if(highlight[x][j]==1) {
    			SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
    			printf("%c", '^');
    			SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    		} else if (game_map[x][j] == '#') {
    			SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    			printf("%c", game_map[x][j]);
    			SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    		} else if (game_map[x][j] == '@') {
    			SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    			printf("%c", game_map[x][j]);
    			SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    		} else if (game_map[x][j] == '*') {
    			SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    			printf("%c", game_map[x][j]);
    			SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    		} else if (game_map[x][j] == '0') printf("%c", ' ');
    		else printf("%c", game_map[x][j]);
    	}
    	if(x!=0) {
    		cout << "|"<<endl;
    	} else {
    		cout<<endl;
    	}
    }
    int dx[8]= {-1,0,1,-1,1,-1,0,1},dy[8]= {-1,-1,-1,0,0,1,1,1}; //偏移量
    void bfs(int x,int y) {
    	for(int i=0; i<8; i++) {
    		if(game_answer[x+dx[i]][y+dy[i]]=='0'&&game_map[x+dx[i]][y+dy[i]]=='#'&&x+dx[i]>0&&x+dx[i]<=high&&y+dy[i]>0&&y+dy[i]<=weight) {
    			game_map[x+dx[i]][y+dy[i]]=game_answer[x+dx[i]][y+dy[i]];
    			bfs(x+dx[i],y+dy[i]);
    		} else if(x+dx[i]>0&&x+dx[i]<=high&&y+dy[i]>0&&y+dy[i]<=weight&&game_answer[x+dx[i]][y+dy[i]]!='@') {
    			game_map[x+dx[i]][y+dy[i]]=game_answer[x+dx[i]][y+dy[i]];
    		}
    	}
    	return;
    }//判断空格
    int main() {
    	srand(time(0));
    	HideCursor();
    	out(10);
    	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    	SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
    	while (1) {
    		chose_x=1,chose_y=1,chose_nx=1,chose_ny=1;
    		int chose=1,hard_chose=2;
    		double hard[5]= {0,0,0.075,0.3,0.45};
    		system("cls");
    		out(chose);
    		while(1) {
    			bool end=0;
    			char game = getch();
    			switch (game) {
    				case 72:
    					system("cls");
    					chose = 1;
    					out(chose);
    					break;
    				case 80:
    					system("cls");
    					chose = 0;
    					out(chose);
    					break;
    				case 13:
    					system("cls");
    					if (chose == 0) {
    						out(hard_chose);
    						while (1) {
    							char game_hard = getch();
    							switch (game_hard) {
    								case 72:
    									hard_chose--;
    									break;
    								case 80:
    									hard_chose++;
    									break;
    								case 13:
    									end=1;
    									break;
    							}
    							system("cls");
    							if(hard_chose<2) hard_chose=2;
    							if(hard_chose>4) hard_chose=4;
    							out(hard_chose);
    							if(end==1) break;
    						}
    						end=1;
    					} else end=1;
    			}
    			if(end==1)break;
    		}
    		system("cls");
    		//选择扫雷规则
    		tips=3;
    		while (1) {
    			SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    			cout << "\n\t\t\t\t\t请输入雷阵的长和宽(5<high<=20):" << endl;
    			cout << "\t\t\t\t\thigh:";
    			high=0;
    			string high1;
    			cin>>high1;
    			int n=high1.size();
    			bool cin_f=1;
    			for(int i=0; i<n; i++) {
    				if('0'>high1[i]||'9'<high1[i]) {
    					cin_f=0;
    				}
    				int num=int(high1[i]-'0');
    				high+=num*pow(10,n-i-1);
    			}
    			if (high > 20 || high < 5 || cin_f==0) {
    				system("cls");
    				SetConsoleTextAttribute(hConsole,  FOREGROUND_RED | FOREGROUND_INTENSITY);
    				cout << "\n\t\t\t\t\t请输入正确的 HIGH" << endl;
    				Sleep(10);
    				SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    			} else break;
    		}
    		system("cls");
    		while (1) {
    			cout << "\n\t\t\t\t\t请输入雷阵的长和宽(5<weight<=110):" << endl;
    			Sleep(1);
    			cout << "\t\t\t\t\thigh:" << high << "\n" << "\t\t\t\t\tweight:";
    			weight=0;
    			string weight1;
    			cin>>weight1;
    			int n=weight1.size();
    			bool cin_f=1;
    			for(int i=0; i<n; i++) {
    				if('0'>weight1[i]||'9'<weight1[i]) {
    					cin_f=0;
    				}
    				int num=int(weight1[i]-'0');
    				weight+=num*pow(10,n-i-1);
    			}
    			if (weight > 110 || weight < 5||cin_f==0) {
    				system("cls");
    				SetConsoleTextAttribute(hConsole,  FOREGROUND_RED | FOREGROUND_INTENSITY);
    				cout << "\n\t\t\t\t\t请输入正确的 WEIGHT" << endl;
    				Sleep(10);
    				SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    			} else break;
    		}
    		system("cls");
    		//输入雷阵的长和宽
    		for(int i = 0; i <= high+1; i++) {
    			for (int j = 0; j <= weight+1; j++) {
    				game_map[i][j]='#';
    				game_answer[i][j]=' ';
    				highlight[i][j]=0;
    
    			}
    		}
    		//初始化雷阵
    		int mine_num2=high*weight*hard[hard_chose]*0.9;
    		int mine_num3=high*weight*hard[hard_chose]*1.20;
    		mine_num=getRand(mine_num2,mine_num3);
    		if(mine_num<=1) {
    			mine_num++;
    		}
    		mine_num1=mine_num;
    		while(mine_num1-->0) {
    			if(game_answer[getRand(1,high)][getRand(1,weight)]!='*') {
    				game_answer[getRand(1,high)][getRand(1,weight)]='*';
    			} else {
    				mine_num1++;
    			}
    		}
    		//放雷
    		srand(std::time(0));
    		game_answer[getRand(1,high)][getRand(1,weight)]='@';
    		//放九宫格
    		mine_num=0;
    		for(int i = 1; i <= high; i++) {
    			for (int j = 1; j <= weight; j++) {
    				if(game_answer[i][j]=='*') {
    					mine_num++;
    				}
    			}
    		}
    		mine_num_true=mine_num;
    		//统计雷数
    		game_answer[1][1]=' ';
    		for(int i = 1; i <= high; i++) {
    			for (int j = 1; j <= weight; j++) {
    				int cnt=0;
    				if(game_answer[i][j]!='@'&&game_answer[i][j]!='*') {
    					for(int k=0; k<8; k++) {
    						if(game_answer[i+dx[k]][j+dy[k]]=='*') {
    							cnt++;
    						}
    					}
    					game_answer[i][j]=char(cnt+'0');
    				}
    			}
    		}//计算格子雷数
    		system("cls");
    		double strat=clock();
    		while(1) {
    			ClearW();
    			out(12);
    			bool flag=0;
    			while(1) {
    				char move=getch();
    				bool breakk=0;
    				switch (move) {
    					case 72:
    						chose_nx=chose_x-1;
    						if(chose_nx<1||chose_nx>high) {
    							chose_nx=chose_x;
    						} else {
    						}
    						break;
    					case 80:
    						chose_nx=chose_x+1;
    						if(chose_nx<1||chose_nx>high) {
    							chose_nx=chose_x;
    						}
    						break;
    					case 75:
    						chose_ny=chose_y-1;
    						if(chose_ny<1||chose_ny>weight) {
    							chose_ny=chose_y;
    						}
    						break;
    					case 77:
    						chose_ny=chose_y+1;
    						if(chose_ny<1||chose_ny>weight) {
    							chose_ny=chose_y;
    						}
    						break;
    					case 13:
    						if(game_map[chose_nx][chose_ny]!=game_answer[chose_nx][chose_ny]&&highlight[chose_nx][chose_ny]!=1) {
    							flag=1;
    						}
    						break;
    					case 32:
    						if(highlight[chose_nx][chose_ny]==0&&game_map[chose_nx][chose_ny]!=game_answer[chose_nx][chose_ny]) {
    							highlight[chose_nx][chose_ny]=1;
    							mine_num--;
    							ClearW();
    							out(12);
    							breakk=1;
    						}
    						break;
    					case 47:
    						if(highlight[chose_nx][chose_ny]==1) {
    							highlight[chose_nx][chose_ny]=0;
    							mine_num++;
    							ClearW();
    							out(12);
    							breakk=1;
    						}
    						break;
    					case 't':
    						if(game_answer[chose_nx][chose_ny]!=game_map[chose_nx][chose_ny]&&tips>0) {
    							tips--;
    							if(game_answer[chose_nx][chose_ny]=='*') {
    								mine_num--;
    								highlight[chose_nx][chose_ny]=1;
    							} else {
    								game_map[chose_nx][chose_ny]=game_answer[chose_nx][chose_ny];
    								flag=1;
    							}
    							ClearW();
    							out(12);
    						}
    						break;
    					case 'A':
    						char zhuobi=getch();
    						if(zhuobi=='q') {
    							cout<<endl;
    							out(13);
    						}
    						break;
    				}
    				if(flag==1) {
    					game_map[chose_nx][chose_ny]=game_answer[chose_nx][chose_ny];
    					break;
    				}
    				if(breakk==1) break;
    				chose_y=chose_ny;
    				chose_x=chose_nx;
    				ClearW();
    				for(int i=1; i<=chose_nx; i++) {
    					cout<<endl;
    
    				}
    				if(chose_nx>1) {
    					outline(chose_nx-1);
    				} else {
    					cout<<endl;
    				}
    				outline(chose_nx);
    				if(chose_nx!=high) {
    					outline(chose_nx+1);
    				}
    
    			}
    			ClearW();
    			out(12);
    			if(game_map[chose_nx][chose_ny]=='*'&&flag==1) {
    				ClearW();
    				out(13);
    				gameover=1;
    			}
    			if(game_map[chose_nx][chose_ny]=='@'&&flag==1) {
    				for(int i=0; i<8; i++) {
    					game_map[chose_nx+dx[i]][chose_ny+dy[i]]=game_answer[chose_nx+dx[i]][chose_ny+dy[i]];
    					if(game_answer[chose_nx+dx[i]][chose_ny+dy[i]]=='0') {
    						bfs(chose_nx,chose_ny);
    						ClearW();
    						out(12);
    					}
    				}
    				ClearW();
    				out(12);
    			}
    			if(game_map[chose_nx][chose_ny]=='0'&&flag==1) {
    				bfs(chose_nx,chose_ny);
    				ClearW();
    				out(12);
    			}
    			if(gameover==1) {
    				break;
    			}
    			int ans=0;
    			for(int i = 1; i <= high; i++) {
    				for (int j = 1; j <= weight; j++) {
    					if(game_map[i][j]==game_answer[i][j]||game_answer[i][j]=='*') {
    						ans++;
    					}
    				}
    			}
    			if(ans==high*weight) {
    				SetConsoleTextAttribute(hConsole,  FOREGROUND_RED | FOREGROUND_INTENSITY);
    				system("cls");
    				double end = clock();
    				cout << "\t\t\t  GGGGGG  " << endl;
    				Sleep(100);
    				cout << "\t\t\t G       " << endl;
    				Sleep(100);
    				cout << "\t\t\t G                                           " << endl;
    				Sleep(100);
    				cout << "\t\t\t G           AAAAA   M mm mm   EEEEE      OOOOO  V     V  EEEEE  R RRR"    << endl;
    				Sleep(100);
    				cout << "\t\t\t G     G    A     A  MM  M  M E     E    O     O  V   V  E     E Rr   R" << endl;
    				Sleep(100);
    				cout << "\t\t\t G      G   A     A  M   M  M EEEEEEE    O     O  V   V  EEEEEEE R    " << endl;
    				Sleep(100);
    				cout << "\t\t\t G      G   A     A  M   M  M E          O     O   V V   E       R" << endl;
    				Sleep(100);
    				cout << "\t\t\t  GGGGGG     AAAAAAa M   M  M eEEEEEE     OOOOO     V    eEEEEEE R" << endl;
    				Sleep(1000);
    				system("cls");
    				cout << "\t\t\t\tY      Y  " << endl;
    				Sleep(100);
    				cout << "\t\t\t\t Y    Y   " << endl;
    				Sleep(100);
    				cout << "\t\t\t\t  Y  Y                                       II         " << endl;
    				Sleep(100);
    				cout << "\t\t\t\t   YY   OOOOO   u      u      W    W    W        N nNNNn " << endl;
    				Sleep(100);
    				cout << "\t\t\t\t   YY  O     O  U      U      W   W W   W    II  Nn     n" << endl;
    				Sleep(100);
    				cout << "\t\t\t\t   YY  O     O  U      U      W   W W   W    II  N      N" << endl;
    				Sleep(100);
    				cout << "\t\t\t\t   YY  O     O  U      U       W  W W  W     II  N      N" << endl;
    				Sleep(100);
    				cout << "\t\t\t\t   YY   OOOOO    UUUUUU         WW   WW      II  N      N" << endl;
    				Sleep(100);
    				int time=(end-strat)/1000;
    				game_time=time;
    				if(time<60) {
    					for(int i=1; i<=54; i++) {
    						cout<<" ";
    					}
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    					cout<<"耗时:";
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    					cout<<time;
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    					cout<<"秒";
    				} else if(time==60) {
    					for(int i=1; i<=55; i++) {
    						cout<<" ";
    					}
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    					cout<<"耗时:";
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    					cout<<1;
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    					cout<<"分";
    				} else {
    					for(int i=1; i<=50; i++) {
    						cout<<" ";
    					}
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    					cout<<"耗时:";
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    					cout<<time/60;
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    					cout<<"分";
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    					cout<<time%60;
    					SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    					cout<<"秒";
    				}
    				cout<<endl;
    				if(high*weight*0.07<=time) {
    					for(int i=1; i<=54; i++) {
    						cout<<" ";
    					}
    					cout<<"So fast!";
    				}
    				break;
    			}
    		}
    		SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
    		cout << "\n\t\t\t\t\t\t输入任意键继(输入后按Enter)"	;
    		cout << "\n\t\t\t\t\t\t"	;
    		char gameover2;
    		cin >> gameover2;
    		SetConsoleTextAttribute(hConsole,  FOREGROUND_RED | FOREGROUND_INTENSITY);
    		ofstream outfile("扫雷游戏记录hhh.txt", ios::app);
    		SYSTEMTIME sys;
    		GetLocalTime(&sys);
    		outfile << "\n\n\t\t\t" << sys.wYear << "年" << sys.wMonth << "月" << sys.wDay << "日      " << sys.wHour;
    		if (sys.wMinute < 10)outfile << ":0" << sys.wMinute;
    		else outfile << ":" << sys.wMinute;
    		if (sys.wSecond < 10)outfile << ":0" << sys.wSecond;
    		outfile << "\n\n\t\t\t" << "weight:" <<weight;
    		outfile << "\t" << "high:" <<high;
    		outfile << "\n\n\t\t\t" << "难度:";
    		if (hard_chose==2) {
    			outfile<<"简单";
    		} else if(hard_chose==3) {
    			outfile <<"普通";
    		} else {
    			outfile<<"困难";
    		}
    		if(gameover==0) {
    			outfile << "\n\n\t\t\t"<<"赢!";
    			outfile << "\n\n\t\t\t";
    			if(game_time<60) {
    				outfile<<"耗时:";
    				outfile<<game_time;
    				outfile<<"秒";
    			} else if(game_time%60==0) {
    				outfile<<"耗时:";
    				outfile<<game_time/60;
    				outfile<<"分";
    			} else {
    				outfile<<"耗时:";
    				outfile<<game_time/60;
    				outfile<<"分";
    				outfile<<game_time%60;
    				outfile<<"秒";
    			}
    		} else {
    			outfile << "\n\n\t\t\t"<<"败!";
    		}
    		outfile.close();
    		gameover=0;
    		system("cls");
    	}
    	return 0;
    }
    
    
  • Recent Activities