快来看看啊!题目+游戏+团队!
  • 板块灌水区
  • 楼主Tom2
  • 当前回复1
  • 已保存回复1
  • 发布时间2025/1/19 15:40
  • 上次更新2025/1/19 15:42:32
查看原帖
快来看看啊!题目+游戏+团队!
1135878
Tom2楼主2025/1/19 15:40

游戏:

#include <bits/stdc++.h>
#include <windows.h>
#include <dos.h>
#include <stdio.h>
using namespace std;

int num[25][25],Flip[25][25],boom[25][25],mark[25][25];
int Flipping = 0,Number_of_markings = 0,Number_mine = 40,sx = 1,sy = 1; // 11
bool over = 0;

void SetColor(int ForgC){
    WORD wColor;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    if (GetConsoleScreenBufferInfo(hStdOut, &csbi)){
        wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
        SetConsoleTextAttribute(hStdOut, wColor);
    }
}

void mine(){
	for(int i = 1;i <= Number_mine;i++){
		srand(time(0));
		int sum_x = rand() % 20 + 1,sum_y = rand() % 20 + 1;
		while(boom[sum_x][sum_y] == 1){
			sum_x = rand() % 20 + 1,sum_y = rand() % 20 + 1;
		}
		boom[sum_x][sum_y] = 1;
	}
}

void initialization(){
	for(int i = 1;i <= 20;i++){
		for(int j = 1;j <= 20;j++){
			if(boom[i + 1][j + 1]){
				num[i][j]++;
			}
			if(boom[i + 1][j]){
				num[i][j]++;
			}
			if(boom[i + 1][j - 1]){
				num[i][j]++;
			}
			if(boom[i][j + 1]){
				num[i][j]++;
			}
			if(boom[i][j - 1]){
				num[i][j]++;
			}
			if(boom[i - 1][j + 1]){
				num[i][j]++;
			}
			if(boom[i - 1][j]){
				num[i][j]++;
			}
			if(boom[i - 1][j - 1]){
				num[i][j]++;
			}
		}
	}
} 

void Print_interface(){
	system("cls");
	SetColor(12);
	cout << "    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 →x" << endl; 
	for(int i = 1;i <= 20;i++){
		SetColor(12);
		cout << i << " ";
		if(i != 10){
			cout << " ";
		}
		if(i <= 10){
			cout << " ";
		}
		for(int j = 1;j <= 20;j++){
			if(!Flip[i][j]){
				if(mark[i][j]){
					if(sx == i || sy == j){
						SetColor(14);
					}else{
						SetColor(12);
					}
					cout << "* ";
				}else{
					if(sx == i || sy == j){
						SetColor(14);
					}else{
						SetColor(10);
					}
					cout << "? ";
				}
			}else{
				if(sx == i || sy == j){
					SetColor(14);
				}else{
					SetColor(15);
				}
				cout << num[i][j] << " ";
			}
			if(j >= 10){
				cout << " ";
			}
		}
		cout << endl;
	}
	cout << " ↓" << endl << " y" << endl;
}

void play_game(){
	int x,y,k;
	cout << endl << "请输入选定的格子坐标(输入:行,列)";
	cin >> x >> y;
	while(!(x >= 1 && x <= 20) || !(y >= 1 && y <= 20)){
		cout << "输入不规范,请重新输入:";
		cin >> x >> y;
	}
	sx = x,sy = y;
	system("cls");
	Print_interface();
	cout << "坐标:(行: " << sx << "   列:" << sy << ")" << endl;
	cout << "请输入干的事(翻开输0,标记输1,取消输2)";
	cin >> k;
	while(k != 0 && k != 1 && k != 2){
		cout << "输入不规范,请重新输入:";
		cin >> k;
	}
	if(k == 0){
		if(Flip[x][y]){
			cout << "该格子已被翻过!";
			Sleep(1000);
		}else{
			Flip[x][y] = 1;
			if(mark[x][y]){
				mark[x][y] = 0;
				Number_of_markings--;
			}
			if(boom[x][y]){
				system("cls");
				cout << "炸弹爆炸!GAME OVER!";
				over = 1;
			}else{
				Flipping++;
			}
		}
	}else if(k == 1){
		if(mark[x][y]){
			cout << "该格子已被标记!";
			Sleep(1000);
		}else if(Flip[x][y]){
			cout << "该格子已被翻过,不能标记!";
			Sleep(1000); 
		}else{
			if(!boom[x][y]){
				system("cls");
				cout << "这里没有地雷,你浪费了一个旗子,失败!GAME OVER!";
				over = 1;
			}else{
				mark[x][y] = 1;
				Number_of_markings++;
			}
		}
	}else{
		cout << "取消成功";
	}
}

void Special_judgment_0(){
	int Check_0[25][25],mx = 0,my = 1,ans = 0;
	memset(Check_0,0,sizeof(Check_0));
	while(ans < 400){
		mx++,ans++;
		if(mx > 20){
			my++,mx = 1;
		}
		if(Flip[mx][my] && !boom[mx][my] && num[mx][my] == 0){
			bool flag = 0;
 			if(!Flip[mx + 1][my + 1]){
				Flip[mx + 1][my + 1] = 1,flag = 1,Flipping++;
			}
			if(!Flip[mx][my + 1]){
				Flip[mx][my + 1] = 1,flag = 1,Flipping++;
			}
			if(!Flip[mx - 1][my + 1]){
				Flip[mx - 1][my + 1] = 1,flag = 1,Flipping++;
			}
			if(!Flip[mx + 1][my]){
				Flip[mx + 1][my] = 1,flag = 1,Flipping++;
			}
			if(!Flip[mx - 1][my]){
				Flip[mx - 1][my] = 1,flag = 1,Flipping++;
			}
			if(!Flip[mx + 1][my - 1]){
				Flip[mx + 1][my - 1] = 1,flag = 1,Flipping++;
			}
			if(!Flip[mx][my - 1]){
				Flip[mx][my - 1] = 1,flag = 1,Flipping++;
			}
			if(!Flip[mx - 1][my - 1]){
				Flip[mx - 1][my - 1] = 1,flag = 1,Flipping++;
			}
			if(flag){
				ans = 0,mx = 0,my = 1;
			}
		}
	}
}

void logo(){
	system("color 0C");
	cout << "                  C";
	Sleep(500);
	system("color 0F");
	cout << "h";
	Sleep(500);
	system("color 03");
	cout << "e";
	Sleep(500);
	system("color 04");
	cout << "s";
	Sleep(500);
	system("color 02");
	cout << "s";
	Sleep(500);
	cout << endl; 
	Sleep(500);
	system("color 06");
	cout << "                 S";
	Sleep(500);
	system("color 0A");
	cout << "t";
	Sleep(500);
	system("color 0B");
	cout << "u";
	Sleep(500);
	system("color 0C");
	cout << "d";
	Sleep(500);
	system("color 0D");
	cout << "i";
	Sleep(500);
	system("color 0E");
	cout << "o" << endl;
	Sleep(3000);
	cout << endl;
	cout << endl;
	system("color 07");
	cout << "                弈棋工作室" << endl;
	Sleep(1000); 
	cout << "                  出品" << endl;
	Sleep(5000); 
	system("cls");
	cout << "       健康游戏忠告" << endl;
	cout << "抵制不良游戏,拒绝盗版游戏。" << endl;
	cout << "注意自我保护,谨防受骗上当。" << endl;
	cout << "适度游戏益脑,沉迷游戏伤身。" << endl;
	cout << "合理安排时间,享受健康生活。" << endl;
	Sleep(10000);
	system("cls"); 
}

void Play_Game(){
	system("cls");
	cout << "扫雷v0.0.24" << endl;
	cout << "制作人:邱弈棋" << endl;
	cout << "说明:	本游戏默认的的网格为20×20网格,地雷数有40个" << endl;
	cout << "---------------更新榜---------------" << endl;
	cout << "|v0.0.24更新:                     |" << endl;
	cout << "|1.修复已知BUG                     |" << endl;
	cout << "|2.更新游戏体验                    |" << endl;
	cout << "------------------------------------" << endl;
	cout << "输入play开始游戏,输入modifier打开修改器,输入其他退出!" << endl; 
	string p;
	cin >> p;
	if(p == "play"){
		system("cls");
		cout << "进入成功!";
		Sleep(1000);
		system("cls");
		mine();
		initialization();
		while(Flipping != 400 - Number_mine && Number_of_markings != Number_mine){
			Print_interface();
			play_game();	
			Special_judgment_0();
			if(over){
				break;	
			}
		}
		if(!over){
			system("cls");
			cout << "你赢了。";
		}
	}else if(p == "modifier"){
		system("cls");
		int x;
		cout << "请选择:1.更改地雷个数  2.待开发(退出):";
		cin >> x;
		while(x != 1 && x != 2){
			cout << "输入不规范,请重新输入:";
			cin >> x;
		}
		if(x == 1){
			cout << "输入地雷数(1~400):";
			cin >> Number_mine;
			while(!(1 <= Number_mine && Number_mine <= 400)){
				cout << "输入不规范,请重新输入:";
				cin >> Number_mine;
			}
			cout << "更改成功!";
			Sleep(1000);
			Play_Game();
		}
		if(x == 2){
			system("cls");
			Sleep(1000);
			cout << "退出成功!";
			Play_Game();
		}
	}else{
		system("cls");
		cout << "退出成功!";
	}
	return ;
}

int main(){
	system("title 扫雷v0.0.24");
	logo();
	if(MessageBox(NULL,"该游戏禁止抄袭,是否遵守?","玩家守则",MB_YESNO) == IDNO){
		system("cls"); 
	}else{
		Play_Game();
	}
	return 0;
}

题目:T565067 厉害的皇后1.0

团队:洛谷先锋刷题队

2025/1/19 15:40
加载中...