跳到正文

休闲·娱乐

C++ 小游戏汇总

miller2014约 605 分钟
原文

这是 2026年1月29日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2025年7月30日
收录
2026年1月29日
更新
2026年11月13日
篇幅
约 605 分钟

版本

  1. v2当前
  2. v1

跑酷

C++
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
#define Nor if(B[b].x<5) B[b].x=5;
#define Out1 Bx1-Bvx1<=6||Bx1-Bvx1>=28||By1-Bvy1<=7||By1-Bvy1>=27
#define Out2 Bx2-Bvx2<=6||Bx2-Bvx2>=28||By2-Bvy2<=7||By2-Bvy2>=27
#define Chang1 {Bwhat1=0;Bvx1=Bvy1=0;memset(Bgo1,0,sizeof(Bgo1));}
#define Chang2 {Bwhat2=0;Bvx2=Bvy2=0;memset(Bgo2,0,sizeof(Bgo2));}
#define Chang3 {Bwhat3=0;Bvx3=Bvy3=0;memset(Bgo3,0,sizeof(Bgo3));}
using namespace std;
int ti(float a) {
	return ((int)(a * 10 + 5)) / 10;
}
void Setpos(float x, float y) {
	COORD pos;
	pos.X = ti(y * 4) / 2;
	pos.Y = ti(x);
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void Color(int a) {
	if (a == 0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	if (a == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
	if (a == 2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
	if (a == 3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
	if (a == 4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
	if (a == 5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
	if (a == 6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
	if (a == 7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	if (a == 8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
	if (a == 9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE);
	if (a == 10) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_BLUE);
	if (a == 11) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_BLUE);
	if (a == 12) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN);
	if (a == 13) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	if (a == 14) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE);
}
int Blomax, Ren, Exp, Expmax, Lv, Lvl, Ice, Drug, ar1, ar2, Tar1, Tar2, bl, br, Win, T, Tb, Sy, Up, Upt, Down, u1, u2, Kill, Killb, L, Ll[4], Li, D, Gd[10], Biao, Fire, Fir, Water, Thun, Wind, Magne, I[20][2], ib, Dis, Disb, Dis1, Disb1, Boss, Bblo, Bblomax, Bwhat1, Bwhat2, Bwhat3, Bgo1[10], Bgo2[10], Bgo3[10], Bbr, Bbl, Bl[4];
float X, Y, Vx, Vy, Ding, Blo, Hui, Bx1, By1, Bx2, By2, Bx3, By3, Bvx1, Bvy1, Bvx2, Bvy2, Bvx3, Bvy3, Bway[1001][2];
struct bullet {
	float x, y, vx, vy;
	int what;
	int a, t, How;
	int life;
	bool kill;
} B[100001];
void Map(int a, int b);
void Pan(int a, float x, float y, int b) {
	float Nox[4], Noy[4];
	Nox[0] = X, Noy[0] = Y;
	if (Down == 1 && X == 22) Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = X - 1, Noy[2] = Y - 0.5;
	else if (Down == 2) Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = -10, Noy[2] = -10;
	else if (Down == 1 || X < 18) Nox[1] = X - 1, Noy[1] = Y - 0.5, Nox[2] = -10, Noy[2] = -10;
	else Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = X - 1, Noy[2] = Y - 0.5;
	for (int i = 0; i < 3; i++) {
		if (a == -1) {
			if (abs(x - Nox[i]) + abs(y - Noy[i]) < 1.5) {
				if (B[b].what == -10)Exp += 2;
				if (B[b].what == -11)Exp += 1;
				B[b].life = 0;
				if (B[b].life == 0 && b == bl) bl++;
				Map(3, b);
				break;
			}
		}
		if (a == -2) {
			if (abs(x - Nox[i]) + abs(y - Noy[i]) < 2.5) {
				if (B[b].what == -2)Exp += 5, Biao += 5;
				if (B[b].what == -3)Fire = 300, Ice = 0, Fir = 3;
				if (B[b].what == -4)Water = 200;
				if (B[b].what == -5) {
					Wind = 70;
					Ding = 28.25;
					Ice = 0;
					if (Y < Ding - 1)Vy = 5;
					else Vy = 0;
					if (Up >= 1) Vx = -5;
					if (Down == 2) Vx = 5;
				}
				if (B[b].what == -6) {
					Thun = 200;
					system("color 1F");
					Sleep(20);
					system("color 6F");
					Sleep(10);
					system("color 0F");
				}
				if (B[b].what == -7)Magne = 300;
				if (B[b].what == -8)Ice = 0, Drug = 0, Blo = fmin((float)Blomax, Blo + 20);
				if (B[b].what == -9)Exp = fmin((float)Expmax, Exp + 20);
				B[b].life = 0;
				if (B[b].life == 0 && b == bl) bl++;
				Map(3, b);
				break;
			}
		}
	}
	if (Wind == 0 && Thun == 0 && (B[b].kill != 0 || Killb >= 15 || Ren == 1 && Killb > 0)) return;
	for (int i = 0; i < 3; i++) {
		if ((Wind >= 1 || Thun >= 1) && abs(x - Nox[i]) + abs(y - Noy[i]) < 2.5) {
			if (B[b].what < 98)Exp += 2;
			B[b].life = 0;
			Map(3, b);
			break;
		}
		if (a == 1) {
			if (abs(x - Nox[i]) < 0.5 && abs(y - Noy[i]) < 1) {
				if (B[b].what >= 99)Blo -= 10;
				if (B[b].what == 14)Blo -= 15, Ice = 100, B[b].life = 0;
				else if (B[b].what == 15)Blo -= 20, Ice = 0, B[b].life = 0;
				else if (B[b].what == 17)Blo -= 5, Drug = 100, B[b].life = 0;
				else if (B[b].what >= 13 && B[b].what <= 17)Blo -= 10, B[b].life = 0;
				else Blo -= 15;
				B[b].kill = 1, Killb = 20;
				Kill = 1;
				Map(3, b);
				break;
			}
		}
		if (a == 2 || a == 6 || a == 8 || a == 9 || a == 10 || a == 11 || a == 12) {
			if (abs(x - Nox[i]) + abs(y - Noy[i]) < 1.5) {
				if (a == 2)Blo -= 20;
				else if (a == 8)Blo -= 10;
				else Blo -= 15;
				B[b].kill = 1, Killb = 20;
				Kill = 1;
				if (a != 2) {
					B[b].life = 0;
					if (B[b].life == 0 && b == bl) bl++;
					Map(3, b);
					break;
				}
			}
		}
		if (a == 4) {
			if ((Wind >= 1 || Thun >= 1) && abs(x - Nox[i]) < 1.5 && Noy[i] - y <= 0 && Noy[i] - y >= -8) {
				if (B[b].what < 98)Exp += 2;
				B[b].life = 0;
				Map(3, b);
				break;
			}
			if (abs(x - Nox[i]) < 1 && Noy[i] - y <= 0 && Noy[i] - y >= -8) {
				Blo -= 25, B[b].kill = 1, Killb = 20;
				Kill = 1;
				Vy = -1;
				Y -= 0.5;
				break;
			}
		}
	}
}
void Map(int a, int b) {
	Color(0);
	if (a == -1) {
		if (Boss == 1 || Boss == 6) {
			if (Bwhat1 == 5) {
				if (ti(Bx1) == 20)Setpos(Bx1, By1), cout << "==";
				else Setpos(Bx1, By1), cout << "  ";
			} else {
				Setpos(Bx1 - 1, By1 - 0.5), cout << "    ";
				Setpos(Bx1, By1 - 1), cout << "      ";
				Setpos(Bx1 + 1, By1 - 0.5), cout << "    ";
				if (abs(ti(Bx1) - 20) <= 1)Setpos(20, By1 - 1), cout << "======";
			}
		}
		if (Boss == 2 || Boss == 6) {
			Setpos(Bx2 - 1, By2 - 1);
			cout << "    ";
			Setpos(Bx2, By2 - 1);
			cout << "      ";
			Setpos(Bx2 + 1, By2 - 1), cout << "      ";
			Color(0);
			if (abs(ti(Bx2) - 20) <= 1)Setpos(20, By2 - 1), cout << "======";
		}
		if (Boss == 3 || Boss == 6) {
			Setpos(Bx3 - 1, By3 - 0.5);
			cout << "     ";
			Setpos(Bx3, By3);
			cout << "  ";
			Setpos(Bx3 + 1, By3 - 1), cout << "      ";
			Color(0);
			if (abs(ti(Bx3) - 20) <= 1)Setpos(20, By3 - 1), cout << "=======";
		}
		if (X < 0)return;
		if (X >= 17 && X <= 19) {
			Setpos(X - 1, Y);
			cout << "  ";
			Setpos(X, Y - 1);
			cout << "   ";
			Setpos(X + 1, Y - 1), cout << "   ";
		} else if (X <= 23 && X >= 21) {
			Setpos(X + 1, Y);
			cout << "  ";
			Setpos(X, Y - 1);
			cout << "   ";
			Setpos(X - 1, Y - 1), cout << "    ";
		} else if (X > 23) {
			Setpos(X, Y - 1);
			cout << "    ";
			Setpos(X - 1, Y - 0.5), cout << "   ";
		} else if (X < 17 && Upt != 0) {
			Setpos(X, Y - 1);
			cout << "    ";
			Setpos(X + 1, Y - 1.5), cout << "    ";
		} else if (X < 17) {
			Setpos(X, Y - 1);
			cout << "    ";
			Setpos(X + 1, Y - 0.5), cout << "   ";
		}
		if (Thun > 0) {
			Setpos(X - 2, Y - 1), cout << "    ";
			Setpos(X + 2, Y - 1), cout << "    ";
			Setpos(X, Y + 2), cout << "  ";
			Setpos(X, Y - 2.5), cout << "  ";
			Setpos(X - 1, Y + 1), cout << "  ";
			Setpos(X + 1, Y + 1), cout << "  ";
			Setpos(X - 1, Y - 2), cout << "  ";
			Setpos(X + 1, Y - 2), cout << "  ";
			Setpos(20, Y - 2.5), cout << "============";
		}
		if (Wind != 0) {
			Setpos(X + 1, Y - 5);
			cout << "        ";
			Setpos(X, Y - 5);
			cout << "        ";
			Setpos(X - 1, Y - 5);
			cout << "        ";
			Setpos(20, Y - 5), cout << "========";
		}
		if (Water != 0) {
			Setpos(X, Y - 4);
			cout << "       ";
			Setpos(X + 2, Y - 3.5);
			cout << "     ";
			Setpos(X - 2, Y - 3.5);
			cout << "     ";
			Setpos(X + 1, Y - 3.5);
			cout << "     ";
			Setpos(X - 1, Y - 3.5);
			cout << "     ";
			Setpos(20, Y - 5), cout << "========";
		}
		if (Fire != 0) {
			Setpos(X, Y + 1), cout << "  ";
			Setpos(X + 1, Y), cout << "  ";
			Setpos(X - 1, Y - 1), cout << "  ";
			Setpos(20, Y - 1);
			cout << "======";
		}
	}
	if (a == 0) {
		if (Boss == 1 || Boss == 6) {
			if (Bwhat1 == 5)Color(5), Setpos(Bx1, By1), cout << "█", Color(0);
			else if (Bwhat1 == 4 && Bgo1[1] > 6 && Bgo1[1] < 11)Color(4), Setpos(Bgo1[5] - 1, Bgo1[6]), cout << "︻", Setpos(Bgo1[5], Bgo1[6] - 1), cout << "【", Setpos(Bgo1[5], Bgo1[6] + 1), cout << "】", Setpos(Bgo1[5] + 1, Bgo1[6]), cout << "︼", Color(0);
			else {
				Setpos(Bx1 - 1, By1 - 0.5), Color(0), cout << "●●";
				Setpos(Bx1, By1 - 1);
				if (Bwhat1 == 2 && Bgo1[1] <= 5)Color(1);
				else if (Bwhat1 == 3 && Bgo1[1] <= 5)Color(5);
				else if (Bwhat1 == 6 && Bgo1[1] <= 5)Color(8);
				else Color(4);
				if (Bwhat1 == 4) Setpos(Bx1, By1 - 0.5), cout << "██(";
				else cout << ")██(";
				Setpos(Bx1 + 1, By1 - 0.5), cout << "……";
				Color(0);
			}
		}
		if (Boss == 2 || Boss == 6) {
			Setpos(Bx2 - 1, By2 - 1);
			Color(0), cout << "\\ ";
			Color(0);
			cout << "●";
			Setpos(Bx2, By2 - 1);
			Color(3);
			cout << "◥";
			Color(5), cout << "JJJ";
			Color(0), cout << ">";
			Color(3);
			Setpos(Bx2 + 1, By2 - 1), cout << "◢█◣";
			Color(0);
		}
		if (Boss == 3 || Boss == 6) {
			Setpos(Bx3 - 1, By3 - 0.5);
			if (Bwhat3 == 3 || Bwhat3 == 9) Color(1);
			else if (Bwhat3 == 4 || Bwhat3 == 10) Color(4);
			else if (Bwhat3 == 5 || Bwhat3 == 11) Color(5);
			if (Bwhat3 == 11)cout << ' ';
			else if (Bwhat3 == 6) Color(3);
			else Color(2);
			cout << "●-";
			Setpos(Bx3, By3);
			if (Bwhat3 == 11)cout << "/";
			else cout << "┃";
			Color(0);
			Setpos(Bx3 + 1, By3 - 1), cout << "●●●";
		}
		if (X < 0)return;
		if (Ren == 2) Color(12);
		if (Ren == 3) Color(1);
		if (Ren == 4) Color(3);
		if (Ren == 5) Color(4);
		if (Ren == 6) Color(2);
		if (Drug != 0 && T % 5 != 0) Color(11);
		if (Drug != 0 && T % 5 == 0) Color(11);
		if (Ice != 0) Color(6);
		if (b == 1) Color(8);
		if (Li != 0) Color(5);
		if (Ren == 1 && Killb > 0 && T % 4 < 2) Color(13);
		if (Wind > 0 && T % 4 <= 1) Color(1);
		if (Wind > 0 && T % 4 >= 2) Color(0);
		if (Thun > 0 && T % 4 <= 1) Color(1);
		if (Thun > 0 && T % 4 >= 2) Color(6);
		if (X >= 17 && X <= 19) {
			Setpos(X - 1, Y);
			cout << "●";
			Setpos(X, Y - 1);
			cout << "━/";
			if (T % 10 < 3) Setpos(X + 1, Y - 1), cout << "┛╲";
			else if (T % 10 < 6) Setpos(X + 1, Y - 1), cout << "┦ ";
			else Setpos(X + 1, Y - 1), cout << "╯>";
			if (Wind > 0 && T % 3 == 0) Setpos(X + 1, Y - 1), cout << "┛╲";
			else if (Wind > 0 && T % 3 == 1) Setpos(X + 1, Y - 1), cout << "┦ ";
			else if (Wind > 0 && T % 3 == 2)Setpos(X + 1, Y - 1), cout << "╯>";
		} else if (X <= 23 && X >= 21) {
			Setpos(X + 1, Y);
			cout << "●";
			Setpos(X, Y - 1);
			cout << "━\\";
			if (T % 10 < 3) Setpos(X - 1, Y - 1), cout << "┓╱";
			else if (T % 10 < 6) Setpos(X - 1, Y - 1), cout << "┪ ";
			else Setpos(X - 1, Y - 1), cout << "╮>";
			if (Wind > 0 && T % 3 == 0) Setpos(X - 1, Y - 1), cout << "┓╱";
			else if (Wind > 0 && T % 3 == 1) Setpos(X - 1, Y - 1), cout << "┪ ";
			else if (Wind > 0 && T % 3 == 2)Setpos(X - 1, Y - 1), cout << "╮>";
		} else if (X > 23) {
			Setpos(X, Y - 1);
			cout << "━ ●";
			Setpos(X - 1, Y - 0.5), cout << "│>";
		} else if (X < 17 && Upt != 0) {
			Setpos(X, Y - 1);
			cout << "━ ●";
			Setpos(X + 1, Y - 1.5), cout << "╱ >";
		} else if (X < 17) {
			Setpos(X, Y - 1);
			cout << "━ ●";
			Setpos(X + 1, Y - 0.5), cout << "│>";
		}
		if (Thun > 0) {
			Setpos(X - 2, Y - 1), cout << "▄▄";
			Setpos(X + 2, Y - 1), cout << "▄▄";
			Setpos(X, Y + 2), cout << "▌";
			Setpos(X, Y - 2.5), cout << "▌";
			Setpos(X - 1, Y + 1), cout << "█";
			Setpos(X + 1, Y + 1), cout << "█";
			Setpos(X - 1, Y - 2), cout << "█";
			Setpos(X + 1, Y - 2), cout << "█";
		}
		if (Magne > 0 && T % 7 < 2)Setpos(X, Y), Color(5), cout << "★";
		if (Wind > 1) {
			if (T % 6 < 2)Color(1);
			else Color(0);
			if (T % 8 <= 1) {
				Setpos(X + 1, Y - 5);
				cout << "----  --";
				Setpos(X, Y - 5);
				cout << "-  --- -";
				Setpos(X - 1, Y - 5);
				cout << "--- - --";
			} else if (T % 8 <= 3) {
				Setpos(X + 1, Y - 5);
				cout << "------  ";
				Setpos(X, Y - 5);
				cout << " --  ---";
				Setpos(X - 1, Y - 5);
				cout << "----- - ";
			} else if (T % 8 <= 5) {
				Setpos(X + 1, Y - 5);
				cout << "  ------";
				Setpos(X, Y - 5);
				cout << "-- --  -";
				Setpos(X - 1, Y - 5);
				cout << "- ----- ";
			} else if (T % 8 <= 7) {
				Setpos(X + 1, Y - 5);
				cout << "--  ----";
				Setpos(X, Y - 5);
				cout << " --- -- ";
				Setpos(X - 1, Y - 5);
				cout << "- - ----";
			}
		}
		if (Water != 0) {
			Color(1);
			if (T % 20 < 5) {
				Setpos(X + 2, Y - 3);
				cout << "■";
				Setpos(X + 1, Y - 3.5);
				cout << "■";
				Setpos(X - 1, Y - 2.5);
				cout << "■";
				Setpos(X - 2, Y - 3);
				cout << "■";
			} else if (T % 20 < 10 || T % 20 >= 15) {
				Setpos(X + 2, Y - 3);
				cout << "■";
				Setpos(X, Y - 4);
				cout << "■■";
				Setpos(X - 2, Y - 3);
				cout << "■";
			} else if (T % 20 < 15) {
				Setpos(X + 2, Y - 3.5);
				cout << "■";
				Setpos(X + 1, Y - 3);
				cout << "■";
				Setpos(X - 1, Y - 3.5);
				cout << "■";
				Setpos(X - 2, Y - 3);
				cout << "■";
			}
		}
		if (Fire != 0) {
			if (T % 6 < 3)Color(4);
			else Color(5);
			if (Fir >= 1)Setpos(X, Y + 1), cout << "●";
			if (Fir >= 2)Setpos(X + 1, Y), cout << "●";
			if (Fir >= 3)Setpos(X - 1, Y - 1), cout << "●";
		}
	}
	if (a == 1 || a == 3) {
		if (B[b].what == 1) {
			Nor;
			Setpos(B[b].x, B[b].y - 1);
			if (ti(B[b].x) == 20)cout << "======";
			else cout << "      ";
			if (B[b].life != 0) {
				B[b].y -= B[b].vy;
				Setpos(B[b].x, B[b].y);
				if (B[b].How <= 1) Color(13);
				else Color(4);
				cout << "●";
				if (a == 1) Pan(1, B[b].x, B[b].y, b);
			}
		}
		if (B[b].what == 2) {
			Nor;
			Setpos(B[b].x - 1, B[b].y - 1);
			if (ti(B[b].x - 1) == 20)cout << "======";
			else cout << "      ";
			Setpos(B[b].x, B[b].y - 1);
			if (ti(B[b].x) == 20)cout << "======";
			else cout << "      ";
			Setpos(B[b].x + 1, B[b].y - 1);
			if (ti(B[b].x + 1) == 20)cout << "======";
			else cout << "      ";
			if (B[b].life != 0) {
				B[b].y -= B[b].vy;
				Setpos(B[b].x, B[b].y);
				Color(5);
				if (B[b].How == 0) {
					Setpos(B[b].x - 1, B[b].y), cout << "↑";
					Setpos(B[b].x, B[b].y - 1), cout << "←┼ →";
					Setpos(B[b].x + 1, B[b].y), cout << "↓";
				} else if (B[b].How == 1) {
					Setpos(B[b].x - 1, B[b].y - 1), cout << "↖  ↗";
					Setpos(B[b].x, B[b].y), cout << "╳";
					Setpos(B[b].x + 1, B[b].y - 1), cout << "↙  ↘";
				}
				if (a == 1) Pan(2, B[b].x, B[b].y, b);
			}
		}
		if (B[b].what == 3 || B[b].what == 5) {
			Nor;
			Setpos(B[b].x, B[b].y);
			if (ti(B[b].x) == 20)cout << "==";
			else cout << "  ";
			if (B[b].life != 0) {
				B[b].y -= B[b].vy;
				B[b].x -= B[b].vx;
				Setpos(B[b].x, B[b].y);
				if (B[b].How == 1) Color(5);
				else Color(4);
				cout << "◎";
			}
		}
		if (B[b].what == 4) {
			Nor;
			Setpos(B[b].x, fmax((float)0, B[b].y - 8));
			if (ti(B[b].x) == 20) {
				for (int i = max(0, (int)B[b].y - 8); i <= B[b].y; i++)cout << "==";
			} else {
				for (int i = max(0, (int)B[b].y - 8); i <= B[b].y; i++)cout << "  ";
			}
			if (B[b].life != 0) {
				B[b].y -= B[b].vy;
				Setpos(B[b].x, fmax((float)0, B[b].y - 8));
				Color(6);
				for (int i = max(0, (int)B[b].y - 8); i <= B[b].y; i++)cout << "═";
				if (a == 1) Pan(4, B[b].x, B[b].y, b);
			}
		}
		if (B[b].what == 6 || B[b].what == 8 || B[b].what == 9) {
			Nor;
			Setpos(B[b].x - 1, B[b].y);
			if (ti(B[b].x) - 1 == 20)cout << "==";
			else cout << "  ";
			Setpos(B[b].x + 1, B[b].y);
			if (ti(B[b].x) + 1 == 20)cout << "==";
			else cout << "  ";
			Setpos(B[b].x, B[b].y - 1);
			if (ti(B[b].x) == 20)cout << "======";
			else cout << "      ";
			if (B[b].life != 0) {
				B[b].y -= B[b].vy;
				B[b].x -= B[b].vx;
				Setpos(B[b].x, B[b].y - 1);
				if (B[b].what == 6) {
					if (B[b].How <= 1) Color(1);
					else Color(6);
				}
				if (B[b].what == 9) {
					if (B[b].How <= 1) Color(4);
					else Color(8);
				}
				if (B[b].what == 8)Color(5);
				Setpos(B[b].x - 1, B[b].y);
				cout << "︹";
				Setpos(B[b].x + 1, B[b].y);
				cout << "︺";
				Setpos(B[b].x, B[b].y - 1);
				if (B[b].How % 2 == 1) cout << "〔●〕";
				else cout << "﹝○﹞";
				if (a == 1) Pan(6, B[b].x, B[b].y, b);
			}
		}
		if (B[b].what == 7) {
			Nor;
			Setpos(B[b].x, B[b].y);
			if (B[b].How < 0) for (int i = 19; i >= 20 + B[b].How; i--) {
					Setpos(i, B[b].y);
					cout << "  ";
				}
			if (B[b].How > 0) for (int i = 21; i <= 20 + B[b].How; i++) {
					Setpos(i, B[b].y);
					cout << "  ";
				}
			if (B[b].life != 0) {
				B[b].y -= B[b].vy;
				if (B[b].How < 0) for (int i = 19; i >= 20 + B[b].How; i--) {
						Setpos(i, B[b].y);
						cout << "║";
						if (a == 1) Pan(7, i, B[b].y, b);
					}
				if (B[b].How > 0) for (int i = 21; i <= 20 + B[b].How; i++) {
						Setpos(i, B[b].y);
						cout << "║";
						if (a == 1) Pan(7, i, B[b].y, b);
					}
			}
		}
		if (B[b].what == 10 || B[b].what == 11 || B[b].what == 12) {
			Nor;
			Setpos(B[b].x, B[b].y);
			if (ti(B[b].x) == 20)cout << "==";
			else cout << "  ";
			if (B[b].life != 0) {
				B[b].x -= B[b].vx;
				B[b].y -= B[b].vy;
				if (B[b].How == 1) {
					B[b].vy -= 0.2;
				} else B[b].vx -= 0.35;
				if (B[b].x >= 25) B[b].x = 25, B[b].vx *= -0.8;
				if (B[b].what == 11 && B[b].y <= 1) B[b].y = 1, B[b].vy *= -1;
				if (B[b].what == 12 && B[b].y <= 1) B[b].y = 1, B[b].vx = 0, B[b].vy = -0.5, B[b].How = 1;
				Setpos(B[b].x, B[b].y);
				if (B[b].what == 11)Color(1);
				else if (B[b].what == 12)Color(5);
				else Color(0);
				if (B[b].t % 4 < 2)cout << "▃";
				else cout << "▍";
				if (a == 1) Pan(B[b].what, B[b].x, B[b].y, b);
			}
		}
		if (B[b].what >= 13 && B[b].what <= 17) {
			Nor;
			Setpos(B[b].x, B[b].y);
			if (ti(B[b].x) == 20)cout << "====";
			else cout << "    ";
			if (B[b].life != 0) {
				B[b].x -= B[b].vx;
				B[b].y -= B[b].vy;
				Setpos(B[b].x, B[b].y);
				if (B[b].what == 14) Color(1);
				else if (B[b].what == 15) Color(4);
				else if (B[b].what == 16) Color(5);
				else if (B[b].what == 17) Color(3);
				else Color(2);
				cout << "●";
				if (B[b].what == 14)cout << "*";
				if (B[b].what == 15)cout << "";
				if (B[b].what == 16)cout << "<";
				if (B[b].what == 17)cout << "X";
			}
			if (a == 1) Pan(1, B[b].x, B[b].y, b);
		}
		if (B[b].what == 98 && B[b].life != 0) {
			B[b].y -= B[b].vy;
			Setpos(B[b].x, B[b].y);
			if (ti(B[b].x == 20))cout << "==";
			else cout << "  ";
			if (B[b].y <= 3)B[b].life = 0;
		}
		if (B[b].what >= 99) {
			if (B[b].y <= 3)B[b].life = 0;
			if (B[b].life != 0) {
				B[b].y -= B[b].vy;
				Setpos(B[b].x, B[b].y);
				Color(5);
				if (B[b].what == 99)cout << "█";
				if (B[b].what >= 100 && B[b].what < 200) {
					if (B[b].what % 5 == 0)cout << "我";
					if (B[b].what % 5 == 1)cout << "是";
					if (B[b].what % 5 == 2)cout << "最";
					if (B[b].what % 5 == 3)cout << "强";
					if (B[b].what % 5 == 4)cout << "的";
				}
				if (B[b].what >= 200 && B[b].what < 300) {
					if (B[b].what % 6 == 0)cout << "神";
					if (B[b].what % 6 == 1)cout << "级";
					if (B[b].what % 6 == 2)cout << "怪";
					if (B[b].what % 6 == 3)cout << "物";
					if (B[b].what % 6 == 4)cout << "之";
					if (B[b].what % 6 == 5)cout << "光";
				}
				if (B[b].what >= 300 && B[b].what < 400) {
					if (B[b].what % 8 == 0)cout << "颤";
					if (B[b].what % 8 == 1)cout << "抖";
					if (B[b].what % 8 == 2)cout << "吧";
					if (B[b].what % 8 == 3)cout << "无";
					if (B[b].what % 8 == 4)cout << "能";
					if (B[b].what % 8 == 5)cout << "的";
					if (B[b].what % 8 == 6)cout << "人";
					if (B[b].what % 8 == 7)cout << "类";
				}
				if (B[b].what >= 400 && B[b].what < 500) {
					if (B[b].what % 8 == 0)cout << "还";
					if (B[b].what % 8 == 1)cout << "不";
					if (B[b].what % 8 == 2)cout << "快";
					if (B[b].what % 8 == 3)cout << "跪";
					if (B[b].what % 8 == 4)cout << "倒";
					if (B[b].what % 8 == 5)cout << "在";
					if (B[b].what % 8 == 6)cout << "朕";
					if (B[b].what % 8 == 7)cout << "前";
				}
				if (B[b].what >= 500 && B[b].what < 600) {
					if (B[b].what % 8 == 0)cout << "看";
					if (B[b].what % 8 == 1)cout << "懂";
					if (B[b].what % 8 == 2)cout << "这";
					if (B[b].what % 8 == 3)cout << "句";
					if (B[b].what % 8 == 4)cout << "话";
					if (B[b].what % 8 == 5)cout << "的";
					if (B[b].what % 8 == 6)cout << "是";
					if (B[b].what % 8 == 7)cout << "猪";
				}
				if (a == 1) Pan(1, B[b].x, B[b].y, b);
			}
		}
		if (B[b].what == -1) {
			Nor;
			Setpos(B[b].x, B[b].y);
			if (ti(B[b].x) == 20)cout << "==";
			else cout << "  ";
			if (Boss == 0) B[b].life = 0;
			else if (((Boss == 1 && abs(B[b].x - Bx1) + abs(B[b].y - By1) < 1.5) || (Boss == 2 && abs(B[b].x - Bx2) + abs(B[b].y - By2) < 1.5) || (Boss == 3 && abs(B[b].x - Bx3) + abs(B[b].y - By3) < 1.5) || (B[b].t == 10)) && B[b].life == 1) Bblo -= 8 + Lv * 2, B[b].life = 0;
			if (B[b].life != 0) {
				if (Boss == 1)B[b].x = B[b].x + (Bx1 - B[b].x) / (10 - B[b].t) * 1.0, B[b].y = B[b].y + (By1 - B[b].y) / (10 - B[b].t) * 1.0;
				if (Boss == 2)B[b].x = B[b].x + (Bx2 - B[b].x) / (10 - B[b].t) * 1.0, B[b].y = B[b].y + (By2 - B[b].y) / (10 - B[b].t) * 1.0;
				if (Boss == 3)B[b].x = B[b].x + (Bx3 - B[b].x) / (10 - B[b].t) * 1.0, B[b].y = B[b].y + (By3 - B[b].y) / (10 - B[b].t) * 1.0;
				Setpos(B[b].x, B[b].y);
				Color(7);
				if (B[b].t % 2 == 0) cout << "+";
				else cout << "×";
			}
		}
		if (B[b].what <= -2 && B[b].what >= -9) {
			Nor;
			Setpos(B[b].x - 1, B[b].y);
			if (ti(B[b].x) - 1 == 20)cout << "==";
			else cout << "  ";
			Setpos(B[b].x + 1, B[b].y);
			if (ti(B[b].x) + 1 == 20)cout << "==";
			else cout << "  ";
			Setpos(B[b].x, B[b].y - 1);
			if (ti(B[b].x) == 20)cout << "======";
			else cout << "      ";
			if (B[b].life != 0) {
				B[b].y -= B[b].vy;
				B[b].x -= B[b].vx;
				if (B[b].what <= -3 && B[b].what >= -7) {
					if (B[b].x <= 7)B[b].x = 7;
					if (B[b].x >= 28)B[b].x = 28;
					else if (B[b].x >= B[b].a + 1 && B[b].How == 1)B[b].How = 0;
					else if (B[b].x <= B[b].a - 1 && B[b].How == 0)B[b].How = 1;
					if (B[b].How == 1 && B[b].vx >= -1)B[b].vx -= 0.2;
					if (B[b].How == 0 && B[b].vx <= 1)B[b].vx += 0.2;
				}
				if (B[b].what == -2) Color(3);
				if (B[b].what == -3) Color(4);
				if (B[b].what == -4) Color(1);
				if (B[b].what == -5) Color(0);
				if (B[b].what == -6) Color(6);
				if (B[b].what == -7) Color(5);
				if (B[b].what == -8) Color(2);
				if (B[b].what == -9) Color(14);
				if (T % 7 <= 1 && B[b].what == -5)Color(1);
				else if (T % 7 <= 1)Color(0);
				Setpos(B[b].x - 1, B[b].y);
				cout << "︹";
				Setpos(B[b].x + 1, B[b].y);
				cout << "︺";
				Setpos(B[b].x, B[b].y - 1);
				if (B[b].what == -2) cout << "﹝镖﹞";
				if (B[b].what == -3) cout << "﹝火﹞";
				if (B[b].what == -4) cout << "﹝水﹞";
				if (B[b].what == -5) cout << "﹝风﹞";
				if (B[b].what == -6) cout << "﹝雷﹞";
				if (B[b].what == -7) cout << "﹝磁﹞";
				if (B[b].what == -8) cout << "﹝血﹞";
				if (B[b].what == -9) cout << "﹝忍﹞";
				if (a == 1) Pan(-2, B[b].x, B[b].y, b);
			}
		}
		if (B[b].what == -11 || B[b].what == -12) {
			Nor;
			Setpos(B[b].x, B[b].y);
			if (ti(B[b].x) == 20)cout << "==";
			else cout << "  ";
			if (B[b].life != 0) {
				if (Magne > 0)B[b].How++, B[b].x = B[b].x + (X - B[b].x) / (10 - B[b].How) * 1.0, B[b].y = B[b].y + (Y - B[b].y) / (10 - B[b].How) * 1.0;
				B[b].y -= B[b].vy;
				Setpos(B[b].x, B[b].y);
				if (B[b].what == -10) Color(5);
				if (B[b].what == -11) Color(7);
				if (T % 7 <= 1)Color(0);
				cout << "◆";
				if (a == 1) Pan(-1, B[b].x, B[b].y, b);
			}
		}
		if (B[b].what == -13) {
			Nor;
			Setpos(B[b].x, B[b].y - 0.5);
			if (ti(B[b].x) == 20)cout << "===";
			else cout << "   ";
			if (B[b].life != 0) {
				if (B[b].a == 13880086) {
					if (Boss == 0) B[b].life = 0;
					else if (((Boss == 1 && abs(B[b].x - Bx1) + abs(B[b].y - By1) < 1.5) || (Boss == 2 && abs(B[b].x - Bx2) + abs(B[b].y - By2) < 1.5) || (Boss == 3 && abs(B[b].x - Bx3) + abs(B[b].y - By3) < 1.5) || (B[b].t == 5)) && B[b].life == 1) Bblo -= 8 + Lv * 2, B[b].life = 0;
					if (B[b].life != 0) {
						if (Boss == 1)B[b].x = B[b].x + (Bx1 - B[b].x) / (5 - B[b].t) * 1.0, B[b].y = B[b].y + (By1 - B[b].y) / (5 - B[b].t) * 1.0;
						if (Boss == 2)B[b].x = B[b].x + (Bx2 - B[b].x) / (5 - B[b].t) * 1.0, B[b].y = B[b].y + (By2 - B[b].y) / (5 - B[b].t) * 1.0;
						if (Boss == 3)B[b].x = B[b].x + (Bx3 - B[b].x) / (5 - B[b].t) * 1.0, B[b].y = B[b].y + (By3 - B[b].y) / (5 - B[b].t) * 1.0;
					}
				} else {
					if (B[B[b].a].life == 0) B[b].life = 0;
					else if ((abs(B[b].x - B[B[b].a].x) + abs(B[b].y - B[B[b].a].y) < 1.5 || (B[b].t == 5)) && B[b].life == 1) Exp += 2, B[B[b].a].life = B[b].life = 0;
					if (B[b].life != 0) {
						B[b].x = B[b].x + (B[B[b].a].x - B[b].x) / (5 - B[b].t) * 1.0, B[b].y = B[b].y + (B[B[b].a].y - B[b].y) / (5 - B[b].t) * 1.0;
					}
				}
				Setpos(B[b].x, B[b].y - 0.5);
				if (T % 6 < 3)Color(5);
				else Color(4);
				cout << "●";
			}
		}
	}
	if (br < bl) {
		br = -1, bl = 0;
		memset(B, 0, sizeof(B));
	}
	Color(0);
}
void Move() {
	if (X < 3) X = 3;
	if (Y < 1) Y = 1, Vy = 0;
	if (Y > 29) Y = 29, Vy = 0;
	if (Ice != 0) {
		X -= Vx / 2.0;
		Y += Vy / 2.0;
		Vy = fmax(Vy - 0.025, (float)0);
		if (T % 6 == 0 && Up == 0 && Y < Ding) Y += 0.25;
		if (T % 6 == 3 && Up == 0 && Y >= Ding) Y -= 0.25;
		if (Up == 0 && Y <= Ding - 1.25) Vy = 0.25;
		if (Up == 0 && Y >= Ding + 1.25 && Wind == 0) Vy = -0.25;
		if (Up == 0 && Down == 0 && Vx > 0 && X <= 18) Up = 0, Down = 0, Vx = 0, Vy = 0, X = 18, Setpos(20, Y - 2.5), cout << "==========";
		else if (Down == 2 && X <= 22) Up = 0, Down = 1, Vx = 0, Vy = 0, X = 22, Setpos(20, Y - 2.5), cout << "==========";
		else if (Up == 0 && Down == 1 && Vx < 0 && X >= 22) Up = 0, Down = 1, Vx = 0, Vy = 0, X = 22, Setpos(20, Y - 2.5), cout << "==========";
		else if (Up > 0 && Down == 0 && X > 18) Up = 0, Vx = 0, Vy = 0, X = 18, Setpos(20, Y - 2.5), cout << "==========";
		else if (Down == 2) Vx += 0.175;
		else if (Up > 0 && Upt == 0) Vx -= 0.175;
		else if (Up > 0 && Upt > 0) {
			Vx = fmax(Vx - 0.125, (float)0);
			if (Upt == 1 && T % 2 == 0)Map(-1, 0);
			if (T % 2 == 0)Upt--;
		}
	} else {
		X -= Vx;
		Y += Vy;
		Vy = fmax(Vy - 0.05, (float)0);
		if (Wind == 0) {
			if (T % 6 == 0 && Up == 0 && Y < Ding) Y += 0.5;
			if (T % 6 == 3 && Up == 0 && Y >= Ding) Y -= 0.5;
		} else {
			if (T % 2 == 0 && Up == 0 && Y < Ding) Y += 0.5;
			if (T % 2 == 1 && Up == 0 && Y >= Ding) Y -= 0.5;
		}
		if (Up == 0 && Y <= Ding - 1.25) Vy = 0.5;
		if (Up == 0 && Y >= Ding + 1.25 && Wind == 0) Vy = -0.5;
		if (Up == 0 && Down == 0 && Vx > 0 && X <= 18) Up = 0, Down = 0, Vx = 0, Vy = 0, X = 18, Setpos(20, Y - 2.5), cout << "==========";
		else if (Down == 2 && X <= 22) Up = 0, Down = 1, Vx = 0, Vy = 0, X = 22, Setpos(20, Y - 2.5), cout << "==========";
		else if (Up == 0 && Down == 1 && Vx < 0 && X >= 22) Up = 0, Down = 1, Vx = 0, Vy = 0, X = 22, Setpos(20, Y - 2.5), cout << "==========";
		else if (Up > 0 && Down == 0 && X > 18) Up = 0, Vx = 0, Vy = 0, X = 18, Setpos(20, Y - 2.5), cout << "==========";
		else if (Down == 2) Vx += 0.35;
		else if (Up > 0 && Upt == 0) Vx -= 0.35;
		else if (Up > 0 && Upt > 0) {
			Vx = fmax(Vx - 0.25, (float)0);
			if (Upt == 1)Map(-1, 0);
			Upt--;
		}
	}
	for (int i = bl; i <= br; i++) {
		if (B[i].what < 98)if (B[i].x - B[i].vx <= 5 || B[i].x - B[i].vx >= 30 || B[i].y - B[i].vy <= 0 || B[i].y - B[i].vy >= 30) {
				B[i].life = 0;
				Map(1, i);
			}
		for (int j = 0; j < 20; j++)if (B[i].what > 0 && B[i].life != 0 && abs(B[i].x - I[j][0]) < 2 && B[i].y - I[j][1] <= 2) {
				Setpos(I[j][0], I[j][1]);
				if (I[j][0] == 20) cout << "===";
				else cout << "   ";
				I[j][0] = I[j][1] = -1;
				B[i].life = 0;
				Exp += 2;
			}
		if (B[i].t >= 100)B[i].life = 0;
		if (B[i].life == 0 && i == bl) bl++;
		Map(1, i);
		if (B[i].life == 0) continue;
		else {
			B[i].t++;
			if (B[i].what == 1) {
				if (B[i].y <= 25 && B[i].How == 0) B[i].vy = 0, B[i].How = 1;
				if (B[i].t == 30) B[i].y += 1.5, B[i].How = 2;
				if (B[i].t == 35) B[i].vy = 1.5, B[i].How = 3;
			}
			if (B[i].what == 2) {
				if (B[i].t % 3 == 0) B[i].How = !B[i].How;
			}
			if (B[i].what == 3 || B[i].what == 5) {
				if (B[i].what == 3 && B[i].y <= 20) B[i].vy = 0;
				if (B[i].what == 5 && B[i].y <= 21) B[i].vy = 0;
				if (B[i].t > 30 && B[i].t % 2 == 0) B[i].How = !B[i].How;
				if (B[i].what == 5 && B[i].t <= 30 && B[i].x < X) B[i].vx = -0.2;
				else if (B[i].what == 5 && B[i].t <= 70 && B[i].x > X) B[i].vx = 0.2;
				else B[i].vx = 0;
				if (B[i].t == 45) {
					B[i].life = 0;
					br++;
					B[br].what = 4;
					B[br].x = B[i].x;
					B[br].y = 32;
					B[br].vy = 3;
					B[br].life = 1;
				}
			}
			if (B[i].what == 6 || B[i].what == 8 || B[i].what == 9) {
				if (B[i].vx < 0.25 && B[i].vy < 0.25 && B[i].t >= 50) {
					B[i].life = 0;
					if (B[i].life == 0 && i == bl) bl++;
					Map(1, i);
					break;
				}
				if (B[i].t % 5 == 0) B[i].How = rand() % 4;
				if (B[i].what == 9) {
					if (B[i].t == 7) {
X9:
						float xx = (rand() % 41) / 40.0, yy = (rand() % 41) / 40.0;
						if (xx <= 0.5 && yy <= 0.5) goto X9;
						for (int j = 1; j <= 4; j++) {
							br++, B[br].what = 9;
							B[br].t = 11;
							B[br].x = B[i].x, B[br].y = B[i].y, B[br].vx = xx, B[br].vy = yy;
							if (j % 2 == 0)swap(B[br].vx, B[br].vy), B[br].vy *= -1;
							if (j <= 2)B[br].vx *= -1, B[br].vy *= -1;
							B[br].life = 1;
						}
						B[i].life = 0;
					}
				}
 
				if (B[i].what == 8) {
					if (B[i].x > X && B[i].vx < 1.2) B[i].vx += fmax((float)0, 0.2 - B[i].t / 25);
					if (B[i].x < X && B[i].vx > -1.2) B[i].vx -= fmax((float)0, 0.2 - B[i].t / 25);
					if (B[i].y > Y && B[i].vy < 1.2) B[i].vy += fmax((float)0, 0.2 - B[i].t / 25);
					if (B[i].y < Y && B[i].vy > -1.2) B[i].vy -= fmax((float)0, 0.2 - B[i].t / 25);
				}
			}
			if (B[i].what >= 13 && B[i].what <= 15 && B[i].How != 0) {
				if (B[i].x == B[i].How)B[i].vx = 0, B[i].How = 0;
			}
			if (B[i].what == 16) {
				if (B[i].x < X && B[i].vx >= -1) B[i].vx -= 0.2;
				else if (B[i].x > X && B[i].vx <= 1) B[i].vx += 0.2;
			}
		}
		if (B[i].life == 1 && B[i].a == 0 && B[i].what > 0) {
			if (B[i].y > Y && abs(B[i].x - X) <= 3 && ((B[i].x - X) * (B[i].x - X) + (B[i].y - Y) * (B[i].y - Y)) < Dis) Dis = (B[i].x - X) * (B[i].x - X) + (B[i].y - Y) * (B[i].y - Y), Disb = i;
			else if (((B[i].x - X) * (B[i].x - X) + (B[i].y - Y) * (B[i].y - Y)) < Dis1) Dis1 = (B[i].x - X) * (B[i].x - X) + (B[i].y - Y) * (B[i].y - Y), Disb1 = i;
		}
	}
}
void Guai(int R, int r) {
	if (R == -1) {
		br++;
		B[br].what = -1;
		B[br].x = X + rand() % 3 - 1;
		B[br].y = Y + rand() % 3 - 1;
		B[br].life = 1;
	}
	if (R <= -2 && R >= -11) {
		br++;
		B[br].what = R;
		B[br].x = B[br].a = r;
		B[br].y = 29;
		if (R <= -3 && R >= -7)B[br].vx = -1;
		B[br].vy = 1;
		B[br].life = 1;
	}
	if (R == 0) {
		br++;
		B[br].what = 1;
		B[br].x = r;
		B[br].y = 29;
		B[br].vy = 1;
		B[br].life = 1;
	}
	if (R == 1) {
		br++;
		B[br].what = 2;
		B[br].x = r;
		B[br].y = 29;
		B[br].vy = 1;
		B[br].life = 1;
	}
	if (R == 2 || R == 3) {
		br++;
		B[br].what = 2 * R - 1;
		B[br].x = r;
		B[br].y = 29;
		B[br].vy = 1;
		B[br].life = 1;
	}
	if (R == 4) {
		br++;
		B[br].what = 6;
		if (r < 5)r = 5;
		if (r > 30)r = 30;
		B[br].x = r;
		if (r == 11 || r == 25) B[br].y = 29 - (rand() % 20);
		else B[br].y = 29;
X4:
		B[br].vx = (rand() % 21 - 10) / 30.0;
		B[br].vy = (rand() % 25) / 30.0;
		if (B[br].vx <= 0.8 && B[br].vy <= 0.8)goto X4;
		int rx = rand() % 50;
		if (rx == 0) B[br].vx = 0;
		B[br].life = 1;
	}
	if (R == 5) {
		br++;
		B[br].How = r;
		B[br].what = 7;
		if (B[br].How < 0) B[br].x = 19;
		if (B[br].How > 0) B[br].x = 21;
		B[br].y = 29;
		B[br].vy = 1;
		B[br].life = 1;
	}
}
void CpGuai(int R, float x, float y, float xx, float yy) {
	if (R == 4) {
		br++;
		B[br].what = 6;
		B[br].x = x;
		B[br].y = y;
		B[br].vx = xx;
		B[br].vy = yy;
		B[br].life = 1;
	}
	if (R == 6 || R == 7 || R == 8) {
		br++;
		B[br].what = 4 + R;
		B[br].x = x;
		B[br].y = y;
		B[br].vx = xx;
		B[br].vy = yy;
		B[br].life = 1;
	}
}
void MesGuai(int a, int rr) {
	int R = rand() % rr, r = -10086;
	if (R == 0) {
		if (a == 1) r = (5 + rand() % 8) * 2;
		if (a <= 3 && a != 1) r = 10 + rand() % 16;
		if (a == 4) r = rand() % 75 - 20;
		if (a == 5) r = 2 + rand() % 4;
		if (r != -10086) Guai(a, r);
	}
}
void NorGuai(int a, int b) {
	if (a == 1) {
		if (b == 1 || b == 41) Guai(0, 15), Guai(0, 17), Guai(0, 19);
		if (b == 21 || b == 61) Guai(0, 21), Guai(0, 23), Guai(0, 25);
		if (b == 81) Guai(0, 11), Guai(0, 13), Guai(0, 15), Guai(0, 17), Guai(0, 19);
		if (b == 101 || b == 141) Guai(0, 17), Guai(0, 19), Guai(0, 21), Guai(0, 23), Guai(0, 25);
		if (b == 121) Guai(0, 15), Guai(0, 17), Guai(0, 19), Guai(0, 21), Guai(0, 23);
		if (b >= 160 && b <= 260 && b % 10 == 0) Guai(0, b / 10 - 1);
		if (b >= 270 && b <= 370 && b % 10 == 0) Guai(0, 52 - b / 10);
		if (b >= 460 && b <= 560 && b % 10 == 0) Guai(0, b / 10 - 37), Guai(0, b / 10 - 36), Guai(0, b / 10 - 35);
		if (b >= 570 && b <= 670 && b % 10 == 0) Guai(0, 78 - b / 10), Guai(0, 77 - b / 10), Guai(0, 76 - b / 10);
		if (b >= 760 && b <= 960 && b % 10 == 0) Guai(0, b / 10 - 66), Guai(0, b / 10 - 65), Guai(0, 103 - b / 10), Guai(0, 104 - b / 10);
		if (b >= 1000 && b <= 1300) MesGuai(0, 30 - b / 50);
	}
	if (a == 2) {
		if (b <= 200 && b % 30 == 1) {
			int r = rand() % 4;
			if (r == 1) r = 0;
			for (int i = 0; i < 4; i++) if (i != r) Guai(1, i * 4 + 9);
		}
		if (b > 200 && b <= 220 && b % 5 == 1) Guai(1, 18);
		if (b > 220 && b <= 300 && b % 7 == 1) Guai(1, b / 5 - 26);
		if (b > 350 && b <= 370 && b % 5 == 1) Guai(1, 22);
		if (b > 370 && b <= 450 && b % 7 == 1) Guai(1, 96 - b / 5);
		if (b == 461 || b == 501 || b == 541) Guai(1, 13), Guai(1, 17), Guai(1, 21);
		if (b == 481 || b == 521 || b == 561) Guai(1, 17), Guai(1, 21), Guai(1, 25);
		if (b >= 561 && b <= 861 && b % 20 == 1) Guai(1, b / 40 + 5);
		if (b >= 561 && b <= 861 && b % 20 == 11) Guai(1, 35 - b / 40);
		if (b >= 801 && b <= 961 && b % 15 == 1) Guai(1, 20);
		if (b >= 1000 && b <= 1300) MesGuai(1, 30 - b / 50);
	}
	if (a == 3) {
		if (b == 1 || b == 61) Guai(3, 15), Guai(2, 17), Guai(2, 19);
		if (b == 31 || b == 91) Guai(2, 21), Guai(2, 23), Guai(3, 25);
		if (b >= 120 && b <= 220 && b % 10 == 0) Guai(2, b / 10 + 3);
		if (b >= 240 && b <= 340 && b % 10 == 0) Guai(2, 49 - b / 10);
		if (b >= 360 && b <= 460 && b % 20 == 0) Guai(2, b / 10 - 21), Guai(2, 61 - b / 10);
		if (b >= 480 && b <= 580 && b % 20 == 0) Guai(3, b / 10 - 33), Guai(3, 73 - b / 10);
		if (b >= 600 && b < 750 && b % 30 == 0) {
			for (int i = 0; i < 5; i++) Guai(3, i * 3 + 10);
		}
		if (b >= 750 && b < 830 && b % 10 == 0) if (b <= 200 && b % 40 == 1) Guai(2, X);
		if (b >= 830 && b < 910 && b % 20 == 0) Guai(2, X);
		if (b >= 910 && b < 980 && b % 10 == 0) Guai(2, X);
		if (b >= 1000 && b <= 1300) MesGuai(rand() % 2 + 2, 40 - b / 50);
	}
	if (a == 4) {
		if (b == 1) CpGuai(4, 10, 29, -0.4, 0.7), CpGuai(4, 14, 29, -0.2, 0.7), CpGuai(4, 21, 29, 0, 0.65);
		if (b == 41) CpGuai(4, 10, 29, -0.2, 0.7), CpGuai(4, 14, 29, -0.1, 0.7), CpGuai(4, 18, 29, 0, 0.65);
		if (b == 81) CpGuai(4, 5, 20, -0.4, 0.35), CpGuai(4, 10, 29, -0.4, 0.7), CpGuai(4, 14, 29, -0.2, 0.7), CpGuai(4, 30, 20, 0.25, 0.4), CpGuai(4, 21, 29, 0, 0.65);
		if (b == 121) CpGuai(4, 5, 20, -0.2, 0.35), CpGuai(4, 10, 29, -0.2, 0.7), CpGuai(4, 14, 29, -0.1, 0.7), CpGuai(4, 30, 20, 0.4, 0.4), CpGuai(4, 18, 29, 0, 0.65);
		if (b == 161) CpGuai(4, 10, 29, -0.4, 0.7), CpGuai(4, 14, 29, -0.2, 0.7), CpGuai(4, 21, 29, 0, 0.6), CpGuai(4, 10, 29, -0.2, 0.7), CpGuai(4, 14, 29, -0.1, 0.7), CpGuai(4, 18, 29, 0, 0.65);
		if (b >= 200 && b <= 500 && b % 40 == 1) {
			float r = 0, rr;
			for (int i = 1; i <= 5; i++) {
X5:
				rr = 0.7 + (rand() % 5) / 10.0;
				if (rr == r)goto X5;
				r = rr;
				CpGuai(4, i * 3 + 7, 29, 0, 0.5 + (rand() % 50) / 80.0);
			}
		}
		if (b > 540 && b <= 565 && b % 5 == 1) CpGuai(4, 5, 8, -2, 0.2);
		if (b > 590 && b <= 615 && b % 5 == 1) CpGuai(4, 30, 8, 1.5, 0.2);
		if (b > 640 && b <= 665 && b % 5 == 1) CpGuai(4, 5, 8, -1.5, 0.3);
		if (b > 690 && b <= 715 && b % 5 == 1) CpGuai(4, 30, 8, 2, 0.3);
		if (b >= 750 && b <= 950 && b % 20 == 1) {
			float r = 0, rr;
			for (int i = 1; i <= 3; i++) {
X6:
				rr = 0.7 + (rand() % 5) / 10.0;
				if (rr == r)goto X6;
				r = rr;
				CpGuai(4, i * 5 + 7 + (rand() % 3), 29, 0, 0.5 + (rand() % 50) / 200.0);
			}
		}
		if (b >= 1000 && b <= 1300) MesGuai(4, 5);
	}
}
void RandGood() {
	if (Biao > 0) {
		Biao--;
		Guai(-1, 0);
	}
	if (Gd[1] == 0) {
		Gd[1] = rand() % 1000 + 1;
		if (Win == 7)Gd[1] = 10086;
		Gd[3] = rand() % 16 + 8;
	} else if (Gd[1] <= 5) {
		Guai(-2 - Gd[1], Gd[3]);
		memset(Gd, 0, sizeof(Gd));
	} else if (Gd[1] >= 20 && Gd[1] < 27) {
		Guai(-8, Gd[3]);
		memset(Gd, 0, sizeof(Gd));
	} else if (Gd[1] >= 30 && Gd[1] < 37) {
		Guai(-9, Gd[3]);
		memset(Gd, 0, sizeof(Gd));
	} else if (Gd[1] >= 40 && Gd[1] < 70) {
		Gd[2]++;
		if (Gd[2] % 2 == 1)Guai(-10, Gd[3]);
		if (Gd[2] >= 9)memset(Gd, 0, sizeof(Gd));
	} else if (Gd[1] >= 70 && Gd[1] < 100) {
		Gd[2]++;
		if (Gd[2] % 2 == 1)Guai(-11, Gd[3]);
		if (Gd[2] >= 9)memset(Gd, 0, sizeof(Gd));
	} else if (Boss != 0 && Gd[1] >= 450 && Gd[1] <= 500) {
		Guai(-2, Gd[3]);
		memset(Gd, 0, sizeof(Gd));
	} else Gd[1] = 0;
	for (int i = 0; i < 20; i++) {
		if (I[i][0] == -1) continue;
		Setpos(I[i][0], I[i][1]);
		Color(0);
		if (I[i][0] == 20) cout << "===";
		else cout << "   ";
		I[i][1]++;
		if (I[i][0] >= 28 || I[i][0] <= 0 || I[i][1] >= 29) I[i][0] = I[i][1] = -1;
		else Color(1), Setpos(I[i][0], I[i][1]), cout << "■";
		Color(0);
	}
}
void Panboss(int bx, int by) {
	float Nox[4], Noy[4];
	Nox[0] = X, Noy[0] = Y;
	if (Down == 1 && X == 22) Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = X - 1, Noy[2] = Y - 0.5;
	else if (Down == 2) Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = -10, Noy[2] = -10;
	else if (Down == 1 || X < 18) Nox[1] = X - 1, Noy[1] = Y - 0.5, Nox[2] = -10, Noy[2] = -10;
	else Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = X - 1, Noy[2] = Y - 0.5;
	for (int i = 0; i < 3; i++) {
		if ((Boss == 1 || Boss == 6) && Wind == 0 && Thun == 0 && abs(Nox[i] - bx) < 1 && abs(Noy[i] - by) < 1 && Bgo1[4] == 0) Blo -= 20, Bgo1[4] = 1, Killb = 20, Kill = 1;
		if ((Boss == 2 || Boss == 6) && Wind == 0 && Thun == 0 && abs(Nox[i] - bx) < 1 && abs(Noy[i] - by) < 1 && Bgo2[8] == 0) Blo -= 20, Bgo2[8] = 1, Killb = 20, Kill = 1;
	}
}
void Boss1() {
	for (int j = 0; j < 20; j++)if (abs(Bx1 - I[j][0]) < 2 && By1 - I[j][1] <= 2) {
			Setpos(I[j][0], I[j][1]);
			if (I[j][0] == 20) cout << "===";
			else cout << "   ";
			I[j][0] = I[j][1] = -1;
			Bblo -= 8 + Lv * 2;
			Exp += 2;
		}
	if (Bbr == Bbl && Bbr != 0) Bbr = Bbl = 0;
	for (int i = 1; i <= 3 + (Bbl - Bbr) / 5; i++)if (Bbr < Bbl) {
			Setpos(Bway[Bbr][0], Bway[Bbr][1]);
			if (Bway[Bbr][0] == 20) cout << "==";
			else cout << "  ";
			Bbr++;
		}
	if (Bwhat1 == 5) {
		int bx, by;
		Color(5);
		for (int i = 0; i < 10; i++) {
			bx = Bx1 - i*Bvx1 / 10.0;
			by = By1 - i*Bvy1 / 10.0;
			Setpos(bx, by), cout << "█";
			Bbl++;
			Bway[Bbl][0] = bx;
			Bway[Bbl][1] = by;
		}
		Color(0);
	}
	Bx1 -= Bvx1;
	By1 -= Bvy1;
	if (Bwhat1 == 0) {
X2:
		Bwhat1 = rand() % 7;
		if (Bwhat1 == 2 || Bwhat1 == 3) {
			if (By1 <= 10 || By1 > 25) goto X2;
		}
		if (Bwhat1 == 4) {
			if (By1 <= 15 || Bx1 < 20) goto X2;
			Bgo1[2] = Bx1;
			Bgo1[3] = By1 - 1;
		}
		if (Bwhat1 == 5) {
X0:
			Bgo1[3] = rand() % 4 + 1;
			Bvx1 = (rand() % 101) / 20.0;
			Bvy1 = (rand() % 101) / 20.0;
			if (Bgo1[3] <= 2) Bvx1 *= -1;
			if (Bgo1[3] % 2 == 1) Bvy1 *= -1;
			if (abs(Bvx1) + abs(Bvy1) <= 3 || Out1)goto X0;
		}
		if (Bwhat1 == 6) {
			if (By1 <= 17 || By1 > 25) goto X2;
		}
	}
	if (Bwhat1 == 1) {
		Bgo1[1]++, Bgo1[2]++;
		int R = rand() % (5 - Bgo1[1]), r = rand() % (10 - Bgo1[2]);
		if (Out1) R = 0;
		if (R == 0) {
			int vx = Bvx1, vy = Bvy1;
			Bgo1[1] = 0;
			Bvx1 = (rand() % 101 - 20) / 50.0;
			Bvy1 = (rand() % 101 - 20) / 50.0;
			if (Bgo1[3] <= 2) Bvx1 *= -1;
			if (Bgo1[3] % 2 == 1) Bvy1 *= -1;
			if (Out1) r = 0;
		}
		if (r == 0) Chang1
		}
	if (Bwhat1 == 2) {
		Bgo1[1]++;
		if (Bgo1[1] > 6) {
			Bvy1 = -0.3;
			br++;
			B[br].x = Bx1, B[br].y = By1 - 1;
			B[br].what = 6;
X3:
			B[br].vx = (rand() % 21 - 10) / 40.0;
			B[br].vy = (rand() % 25) / 30.0;
			if (B[br].vx <= 0.8 && B[br].vy <= 0.8)goto X3;
			int rx = rand() % 50;
			if (rx == 0) B[br].vx = 0;
			B[br].life = 1;
		}
		if (Bgo1[1] > 8) Chang1
		}
	if (Bwhat1 == 3) {
		Bgo1[1]++;
		if (Bgo1[1] > 6 && Bgo1[1] % 3 == 0) {
			Bvy1 = -0.3;
			br++;
			B[br].x = Bx1, B[br].y = By1 - 1;
			B[br].what = 8;
			B[br].life = 1;
		}
		if (Bgo1[1] > 15) Chang1
		}
	if (Bwhat1 == 4) {
		Bgo1[1]++;
		if (Bgo1[1] <= 8) {
			Setpos(Bgo1[2], Bgo1[3]);
			if (Bgo1[1] == 1)cout << " ";
			else if (Bgo1[1] > 1 && Bgo1[2] == 20) cout << "==";
			else cout << "  ";
			Bgo1[2]--;
			Setpos(Bgo1[2], Bgo1[3]);
			int r = rand() % 4;
			if (r % 2 == 0) Color(6);
			else Color(9);
			if (r < 2) cout << ") ";
			else cout << "】";
			Color(0);
		}
		if (Bgo1[1] == 6) Bgo1[5] = X, Bgo1[6] = Y;
		if (Bgo1[1] == 11) {
			Map(0, (bool)Kill);
			Setpos(Bgo1[5], Bgo1[6] + 1), cout << "  ";
			Setpos(Bgo1[5], Bgo1[6] - 1), cout << "  ";
			Setpos(Bgo1[5] + 1, Bgo1[6]), cout << "  ";
			Setpos(Bgo1[5] - 1, Bgo1[6]), cout << "  ";
			int bx, by, bvx = Bgo1[2] - Bgo1[5], bvy = Bgo1[3] - Bgo1[6];
			Color(6);
			int i = 0;
			while (1) {
				bx = Bgo1[2] - i*bvx / 30.0;
				by = Bgo1[3] - i*bvy / 30.0;
				if (bx <= 5 || bx >= 30 || by < 0 || by >= 29) break;
				Panboss(bx, by);
				Setpos(bx, by), cout << "█";
				Bbl++;
				Bway[Bbl][0] = bx;
				Bway[Bbl][1] = by;
				i++;
			}
			Color(0);
			Map(-1, 0);
			Chang1
		}
	}
	if (Bwhat1 == 5) {
		Bgo1[1]++, Bgo1[2]++;
		int R = rand() % (5 - Bgo1[1]), r = rand() % (10 - Bgo1[2]);
		if (Out1) R = 0;
		if (R == 0) {
			int vx = Bvx1, vy = Bvy1;
			Bgo1[1] = 0;
X1:
			Bvx1 = (rand() % 101 - 20) / 20.0;
			Bvy1 = (rand() % 101 - 20) / 20.0;
			if (Bgo1[3] <= 2) Bvx1 *= -1;
			if (Bgo1[3] % 2 == 1) Bvy1 *= -1;
			if (abs(Bvx1) + abs(Bvy1) <= 3 || abs(Bvx1 - vx) <= 1 || abs(Bvy1 - vy) <= 1)goto X1;
			if (Out1) r = 0;
		}
		if (r == 0) Chang1
		}
	if (Bwhat1 == 6) {
		Bgo1[1]++;
		if (Bgo1[1] > 6 && Bgo1[1] % 10 == 0) {
			By1 -= 1;
			br++;
			B[br].x = Bx1, B[br].y = By1 - 1;
			B[br].what = 9;
X30:
			B[br].vy = 1;
			B[br].life = 1;
		}
		if (Bgo1[1] > 31) Chang1
		}
}
void Boss2() {
	for (int j = 0; j < 20; j++)if (abs(Bx2 - I[j][0]) < 2 && By2 - I[j][1] <= 2) {
			Setpos(I[j][0], I[j][1]);
			if (I[j][0] == 20) cout << "===";
			else cout << "   ";
			I[j][0] = I[j][1] = -1;
			Bblo -= 8 + Lv * 2;
			Exp += 2;
		}
	if (Bbr == Bbl && Bbr != 0) Bbr = Bbl = 0;
	for (int i = 1; i <= 3 + (Bbl - Bbr) / 5; i++)if (Bbr < Bbl) {
			Setpos(Bway[Bbr][0], Bway[Bbr][1]);
			if (Bway[Bbr][0] == 20) cout << "==";
			else cout << "  ";
			Bbr++;
		}
	Bx2 -= Bvx2;
	By2 -= Bvy2;
	if (Bwhat2 == 0) {
X21:
		Bwhat2 = rand() % 7;
		if (Bwhat2 == 2) {
X31:
			for (int i = 1; i <= 3; i++) {
				Bgo2[i * 2 + 1] = rand() % 28 + 1, Bgo2[i * 2] = rand() % 25 + 5;
				if ((abs(Bgo2[i * 2] - Bx2) <= 2 && abs(Bgo2[i * 2 + 1] - By2) <= 2) || (abs(Bgo2[i * 2] - X) <= 2 && abs(Bgo2[i * 2 + 1] - Y) <= 2))goto X31;
			}
			if (Bgo2[2] == Bgo2[4] || Bgo2[2] == Bgo2[6] || Bgo2[6] == Bgo2[4] || Bgo2[5] == Bgo2[3] || Bgo2[3] == Bgo2[7] || Bgo2[5] == Bgo2[7]) goto X31;
		}
		if (Bwhat2 == 3) {
			Bgo2[2] = rand() % 2;
		}
		if (Bwhat2 == 4 || Bwhat2 == 5 || Bwhat2 == 6) {
			Bvy2 = -1.5;
			Bvx2 = -0.5;
		}
	}
	if (Bwhat2 == 1) {
		Bgo2[1]++, Bgo2[2]++;
		int R = rand() % (5 - Bgo2[1]), r = rand() % (30 - Bgo2[2]);
		if (Out2) R = 0;
		if (R == 0) {
			int vx = Bvx2, vy = Bvy2;
			Bgo2[1] = 0;
			Bvx2 = (rand() % 101 - 20) / 50.0;
			Bvy2 = (rand() % 101 - 20) / 50.0;
			if (Bgo2[3] <= 2) Bvx2 *= -1;
			if (Bgo2[3] % 2 == 1) Bvy2 *= -1;
			if (Out2) r = 0;
		}
		if (r == 0) Chang2
		}
	if (Bwhat2 == 2) {
		Bgo2[1]++;
		float bx, by, bvx, bvy;
		if (Bgo2[1] < 21) {
			for (int i = 1; i <= 3; i++) {
				bvx = Bgo2[i * 2] - Bx2, bvy = Bgo2[i * 2 + 1] - By2;
				if (Bgo2[1] <= 10) {
					Setpos(Bx2 + (Bgo2[1] - 1)*bvx / 10.0, By2 + (Bgo2[1] - 1)*bvy / 10.0);
					if (abs(Bx2 + (Bgo2[1] - 1) * bvx / 10.0 - 20) < 0.5)cout << "==";
					else cout << "  ";
					bx = Bx2 + Bgo2[1] * bvx / 10.0;
					by = By2 + Bgo2[1] * bvy / 10.0;
					Setpos(bx, by);
				} else Setpos(Bgo2[i * 2], Bgo2[i * 2 + 1]);
				int r = rand() % 4;
				if (r % 2 == 0) Color(3);
				else Color(10);
				if (r <= 1) cout << "×";
				else cout << "+";
				Color(0);
			}
		}
		if (Bgo2[1] == 21) {
			Map(0, (bool)Kill);
			Color(3);
			int j = 0;
			for (int j = 0; j <= 30; j++)for (int i = 1; i <= 3; i++)for (int k = 1; k <= 4; k++) {
						if (k == 1) bvx = j, bvy = 0;
						if (k == 2) bvx = -j, bvy = 0;
						if (k == 3) bvx = 0, bvy = j;
						if (k == 4) bvx = 0, bvy = -j;
						bx = Bgo2[i * 2] + bvx, by = Bgo2[i * 2 + 1] + bvy;
						if (bx <= 5 || bx >= 30 || by < 0 || by >= 30) {
							continue;
						}
						Panboss(bx, by);
						Setpos(bx, by), cout << "█";
						Bbl++;
						Bway[Bbl][0] = bx;
						Bway[Bbl][1] = by;
					}
			Color(0);
			Map(-1, 0);
			Chang2
		}
	}
	if (Bwhat2 == 3) {
		Bgo2[1]++;
		if (Bgo2[1] <= 18) {
			if (Bgo2[3] == 0) Setpos(Bgo2[4] - 3, Bgo2[5]), cout << "  ", Setpos(Bgo2[4] + 3, Bgo2[5]), cout << "  ", Color(0), Setpos(20, Bgo2[5]), cout << "==";
			if (Bgo2[3] == 1) Setpos(Bgo2[4], Bgo2[5] - 3.5), cout << "    ", Setpos(Bgo2[4], Bgo2[5] + 2.5), cout << "    ", Color(0), Setpos(20, Bgo2[5] + 2.5), cout << "====", Setpos(20, Bgo2[5] - 3.5), cout << "====";
			if (Bgo2[1] % 4 == 0)Bgo2[3] = !Bgo2[3];
			if (Bgo2[1] % 6 < 3)Color(3);
			else Color(5);
			if (Bgo2[3] == 0) Setpos(X - 3, Y), cout << "▼", Setpos(X + 3, Y), cout << "▲", Bgo2[4] = (int)(X + 0.5), Bgo2[5] = (int)(Y + 0.5);
			if (Bgo2[3] == 1) Setpos(X, Y - 3), cout << " ", Setpos(X, Y + 3), cout << " ", Bgo2[4] = (int)(X + 0.5), Bgo2[5] = (int)(Y + 0.5);
			Color(0);
		}
		if (Bgo2[1] == 18) {
			if (Bgo2[3] == 0) Setpos(Bgo2[4] - 3, Bgo2[5]), cout << "  ", Setpos(Bgo2[4] + 3, Bgo2[5]), cout << "  ", Color(0), Setpos(20, Bgo2[5]), cout << "==";
			if (Bgo2[3] == 1) Setpos(Bgo2[4], Bgo2[5] - 3.5), cout << "    ", Setpos(Bgo2[4], Bgo2[5] + 2.5), cout << "    ", Color(0), Setpos(20, Bgo2[5] + 2.5), cout << "====", Setpos(20, Bgo2[5] - 3.5), cout << "====";
		}
		if (Bgo2[1] > 18 && Bgo2[1] <= 25) {
			Bgo2[3] = Bgo2[2];
			if (Bgo2[3] == 0) Setpos(Bgo2[4] - 3, Bgo2[5]), cout << "  ", Setpos(Bgo2[4] + 3, Bgo2[5]), cout << "  ", Color(0), Setpos(20, Bgo2[5]), cout << "==";
			if (Bgo2[3] == 1) Setpos(Bgo2[4], Bgo2[5] - 3.5), cout << "    ", Setpos(Bgo2[4], Bgo2[5] + 2.5), cout << "    ", Color(0), Setpos(20, Bgo2[5] + 2.5), cout << "====", Setpos(20, Bgo2[5] - 3.5), cout << "====";
			if (Bgo2[1] % 4 < 2)Color(3);
			else Color(5);
			if (Bgo2[3] == 0) Setpos(Bgo2[4] - 3, Bgo2[5]), cout << "▼", Setpos(Bgo2[4] + 3, Bgo2[5]), cout << "▲";
			if (Bgo2[3] == 1) Setpos(Bgo2[4], Bgo2[5] - 3), cout << " ", Setpos(Bgo2[4], Bgo2[5] + 3), cout << " ";
			Color(0);
		}
		if (Bgo2[1] == 25) {
			if (Bgo2[2] == 0) {
				Color(3);
				for (int i = 4; i <= 29; i++) {
					Setpos(i, Bgo2[5]), cout << "█";
					Bbl++;
					Panboss(i, Bgo2[5]);
					Bway[Bbl][0] = i;
					Bway[Bbl][1] = Bgo2[5];
				}
			}
			if (Bgo2[2] == 1) {
				Color(3);
				for (int i = 0; i <= 28; i++) {
					Setpos(Bgo2[4], i), cout << "█";
					Bbl++;
					Panboss(Bgo2[4], i);
					Bway[Bbl][0] = Bgo2[4];
					Bway[Bbl][1] = i;
				}
			}
			Chang2
		}
	}
	if (Bwhat2 == 4 || Bwhat2 == 5 || Bwhat2 == 6) {
		Bgo2[1]++;
		if (By2 > 27)Bvy2 = 0;
		if (Bx2 > 23)Bvx2 = 0;
		if (Bgo2[1] > 13 && Bgo2[1] % 3 == 0) {
			float t = By2 - Y, g = 0.35;
			if (Boss == 6) t /= 2.0;
			CpGuai(Bwhat2 + 2, Bx2, By2, (Bx2 - X) / t * 1.0 + (t - 1)*g / 2.0, 1);
		}
		if (Bgo2[1] > 20) Chang2
		}
}
void Boss3() {
#define Bean br++;B[br].what=13;B[br].x=Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].life=1;
	for (int j = 0; j < 20; j++)if (abs(Bx3 - I[j][0]) < 2 && By3 - I[j][1] <= 2) {
			Setpos(I[j][0], I[j][1]);
			if (I[j][0] == 20) cout << "===";
			else cout << "   ";
			I[j][0] = I[j][1] = -1;
			Bblo -= 8 + Lv * 2;
			Exp += 2;
		}
	Bx3 -= Bvx3;
	By3 -= Bvy3;
	if (Bwhat3 <= 8) {
		if (Bx3 > X && Bvx3 < 1.5) Bvx3 += 0.3;
		if (Bx3 < X && Bvx3 > -1.5) Bvx3 -= 0.3;
	}
	if (Bwhat3 == 0) {
X22:
		Bwhat3 = rand() % 12;
		if (Bwhat3 == 11 && abs(Bx3 - 20) <= 1)goto X22;
		if (Bwhat3 == 11)Bgo3[2] = rand() % 5;
	}
	if (Bwhat3 == 1) {
		Bgo3[1]++;
		if (Bgo3[1] == 6) {
			br++;
			B[br].what = 13;
			B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
			B[br].vy = 1;
			B[br].vx = 1;
			B[br].How = (int)Bx3 - 4;
			B[br].life = 1;
			br++;
			B[br].what = 13;
			B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
			B[br].vy = 1;
			B[br].vx = -1;
			B[br].How = (int)Bx3 + 2;
			B[br].life = 1;
			br++;
			B[br].what = 13;
			B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
			B[br].vy = 1;
			B[br].life = 1;
			Chang3
		}
	}
	if (Bwhat3 >= 2 && Bwhat3 <= 6) {
		Bgo3[1]++;
		if (Bgo3[1] == 6) {
			br++;
			B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
			B[br].what = 11 + Bwhat3;
			B[br].vy = 0.5 + (rand() % 100) / 80.0;
			if (Bwhat3 == 5)B[br].vy = B[br].vy * 3 / 4.0;
			B[br].life = 1;
			Chang3
		}
	}
	if (Bwhat3 == 7) {
		Bgo3[1]++;
		if (Bgo3[1] == 6) {
			br++;
			B[br].what = 14;
			B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
			B[br].vy = 1;
			B[br].vx = 1;
			B[br].How = (int)Bx3 - 4;
			B[br].life = 1;
			br++;
			B[br].what = 14;
			B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
			B[br].vy = 1;
			B[br].vx = -1;
			B[br].How = (int)Bx3 + 2;
			B[br].life = 1;
			br++;
			B[br].what = 14;
			B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
			B[br].vy = 1;
			B[br].life = 1;
			Chang3
		}
	}
	if (Bwhat3 == 8) {
		Bgo3[1]++;
		if (Bgo3[1] == 6) {
			br++;
			B[br].what = 15;
			B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
			B[br].vy = 1;
			B[br].vx = 1;
			B[br].How = (int)Bx3 - 4;
			B[br].life = 1;
			br++;
			B[br].what = 15;
			B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
			B[br].vy = 1;
			B[br].vx = -1;
			B[br].How = (int)Bx3 + 2;
			B[br].life = 1;
			br++;
			B[br].what = 15;
			B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
			B[br].vy = 1;
			B[br].life = 1;
			Chang3
		}
	}
	if (Bwhat3 == 9) {
		Bvx3 = 0;
		Bgo3[1]++;
		if (Bgo3[1] == 6 || Bgo3[1] == 8) {
			Bean
		}
		if (Bgo3[1] >= 8)Chang3
		}
	if (Bwhat3 == 10) {
		Bvx3 = 0;
		Bgo3[1]++;
		if (Bgo3[1] == 6 || Bgo3[1] == 8 || Bgo3[1] == 10 || Bgo3[1] == 12) {
			Bean
		}
		if (Bgo3[1] >= 12)Chang3
		}
	if (Bwhat3 == 11) {
		Bvx3 = 0;
		Bgo3[1]++;
		if (Bgo3[1] >= 8)for (int i = 1; i <= 4; i++) {
				br++;
				B[br].what = 80 + 100 * Bgo3[2] + Bgo3[1] * 4 + i;
				B[br].x = Bx3 - 1, B[br].y = By3 - 1 + i;
				B[br].vy = 4;
				B[br].life = 1;
				br++;
				B[br].what = 99;
				B[br].x = Bx3, B[br].y = By3 - 1 + i;
				B[br].vy = 4;
				B[br].life = 1;
				br++;
				B[br].what = 99;
				B[br].x = Bx3 - 2, B[br].y = By3 - 1 + i;
				B[br].vy = 4;
				B[br].life = 1;
			}
		if (Bgo3[1] >= 20) {
			for (int i = 1; i <= 4; i++) {
				br++;
				B[br].what = 98;
				B[br].x = Bx3 - 1, B[br].y = By3 - 1 + i;
				B[br].vy = 4;
				B[br].life = 1;
				br++;
				B[br].what = 98;
				B[br].x = Bx3, B[br].y = By3 - 1 + i;
				B[br].vy = 4;
				B[br].life = 1;
				br++;
				B[br].what = 98;
				B[br].x = Bx3 - 2, B[br].y = By3 - 1 + i;
				B[br].vy = 4;
				B[br].life = 1;
			}
			Chang3
		}
	}
}
void Ball(int ball) {
	if (ball == 1) {
		if (Fir < 3 && T % 8 == 0) Fir++;
		if (Fir > 0) {
			br++;
			B[br].what = -13;
			B[br].x = X;
			B[br].y = Y + rand() % 3 - 1;
			B[br].life = 1;
			if (Dis <= 30) B[br].a = Disb, B[Disb].a = 1, Fir--;
			else if (Boss != 0) B[br].a = 13880086, Fir--;
			else if (Dis != 13880087) B[br].a = Disb, B[Disb].a = 1, Fir--;
			else if (Dis1 != 13880087) B[br].a = Disb1, B[Disb1].a = 1, Fir--;
			else B[br].life = 0;
			Dis = Dis1 = 13880087;
		}
	}
	if (ball == 2) {
		if (T % 4 == 0)ib = (ib + 1) % 20, I[ib][1] = Y - 2;
		if (T % 16 == 0)I[ib][0] = X;
		if (T % 16 == 4)I[ib][0] = X - 1;
		if (T % 16 == 8)I[ib][0] = X + 1;
		if (T % 16 == 12)I[ib][0] = X - 2;
		if (T % 12 == 9)I[ib][0] = X + 2;
		if (Water == 1) {
			for (int i = X - 6; i <= X + 6; i++)ib = (ib + 1) % 20, I[ib][0] = i, I[ib][1] = Y - 2 - 0.5 * abs(i - X);
		}
	}
	if (ball == 3) {
		if (Wind > 5) {
			if (Y < Ding - 1)Vy = 5;
			else Vy = 0;
			if (Up >= 1) Vx = -5;
			if (Down == 2) Vx = 5;
		}
		if (Wind < 5) {
			if (Y > Ding - 1)Vy = -5;
			else Vy = 0;
			if (Up >= 1) Vx = -5;
			if (Down == 2) Vx = 5;
		}
		if (Wind == 5) {
			if (Boss == 2) Ding = 12.25;
			else Ding = 6.25;
			if (Boss != 0) Bblo -= 16 + Lv * 4;
			if (Boss == 1) Chang1 if (Boss == 2) Chang2 if (Boss == 3) Chang3 system("color 3F");
			Sleep(20);
			system("color 6F");
			Sleep(10);
			system("color 0F");
			system("cls");
			for (int i = bl; i <= br; i++)if (B[i].what > 0)B[i].life = 0;
			Setpos(20, 0);
			for (int i = 1; i <= 60; i++) printf("=");
		}
	}
	if (ball == 4) {
		if (Thun == 1) {
			if (Boss != 0) Bblo -= 16 + Lv * 4;
			if (Boss == 1) Chang1 if (Boss == 2) Chang2 if (Boss == 3) Chang3 system("color 9F");
			Sleep(20);
			system("color 6F");
			Sleep(10);
			system("color 0F");
			system("cls");
			for (int i = bl; i <= br; i++)if (B[i].what > 0)B[i].life = 0;
			Setpos(20, 0);
			for (int i = 1; i <= 60; i++) printf("=");
		}
	}
	if (ball == 5) {
		system("cls");
		Color(5);
		Setpos(10, 10);
		cout << "新天赋!";
Y:
		int rr = rand() % 4 + 2;
		Setpos(12, 10);
		if (rr == Ren) goto Y;
		if (rr == 2)cout << "瞬跳";
		if (rr == 3)cout << "空之舞";
		if (rr == 4)cout << "三段跳";
		if (rr == 5)cout << "反重力跳跃";
		Setpos(14, 10);
		cout << "当前天赋:";
		if (Ren == 1)cout << "小无敌";
		if (Ren == 2)cout << "瞬跳";
		if (Ren == 3)cout << "空之舞";
		if (Ren == 4)cout << "三段跳";
		if (Ren == 5)cout << "反重力跳跃";
		Setpos(16, 10);
		cout << "换否?(y/n)";
G:
		char g = _getch();
		if (g == 'y')Ren = rr;
		else if (g != 'n')goto G;
		system("cls");
		Setpos(20, 0);
		Color(0);
		for (int i = 1; i <= 60; i++) printf("=");
	}
	if (ball == 6) {
		Color(4);
		for (float i = 1; i <= Bblo; i += Bblomax / 20.0)cout << "▄";
		Color(0);
		cout << ' ' << Bblo << "                              ";
		Color(0);
	}
	if (ball == 7) {
		Color(1);
		if (Win == 7 && T % 6 < 3)Color(3);
		for (float i = 1; i <= Blo; i += Blomax / 20.0)cout << "▄";
		Color(0);
		if (Win == 7 && T % 6 < 3)Color(3);
		printf(" %0.1f                              ", Blo);
	}
}
int main() {
	system("mode con cols=60 lines=37");
	CONSOLE_CURSOR_INFO cursor_info = {1, 0};
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
	srand((unsigned)time(NULL));
	Win = 0;
	Ren = 1;
	Lv = 1;
	Blo = Blomax = 100;
	Expmax = 300;
	Hui = 15;
	X = 18, Y = 6;
ReStart:
	system("cls");
	memset(B, 0, sizeof(B));
	memset(I, -1, sizeof(I));
	T = 0;
	bl = 0;
	br = -1;
	Upt = 0;
Start:
	Blo = Blomax * 100;
	Ding = 6.25;
	memset(Bgo1, 0, sizeof(Bgo1));
	memset(Bgo2, 0, sizeof(Bgo2));
	memset(Bgo3, 0, sizeof(Bgo3));
	if (Win % 2 == 0) T = 0;
	if (Win % 2 == 0 && D == 0) {
		if (Win > 0)Ball(5);
		Boss = 0;
lL:
		L = rand() % 4 + 1;
		for (int i = 0; i <= Win / 2 - 1; i++)if (L == Ll[i]) goto lL;
		Ll[Win / 2] = L;
	}
	if (Win % 2 == 1 && D == 0) {
		if (Win == 7)Boss = 6, T = 0, Blomax += 100;
		else {
bl:
			Boss = rand() % 3 + 1;
			for (int i = 0; i <= 3; i++)if (Boss == Bl[i]) goto bl;
		}
		Bl[Win / 2] = Boss;
		Bwhat1 = Bwhat2 = Bwhat3 = 0, Bx1 = 10, By1 = 20, Bx2 = 15, By2 = 20, Bx3 = 21, By3 = 20;
		system("color 4C");
		Sleep(20);
		system("color 0F");
		Map(0, 1);
		Sleep(1000);
	}
	if (Win % 2 == 1) {
		Bblomax = 500 + (Win / 2) * 500;
		Bblo = Bblomax;
		if (Boss == 2) Ding = 12.25;
	}
	while (1) {
		T++;
		if (Wind == 0) {
			if (GetAsyncKeyState(VK_LEFT) & 0x8000) Vy = -(10 - abs(Ding - Y) * 1.5) / 20.0;
			if (GetAsyncKeyState(VK_RIGHT) & 0x8000) Vy = (10 - abs(Ding - Y) * 1.5) / 20.0;
		}
		if (GetAsyncKeyState(VK_UP) & 0x8000 && u1 == 0) {
			u1++;
			if (Down == 1) {
				Down = 0;
				Up = 0;
				if (Ren == 2)Map(-1, 0), Vx = 0, X = 18, Li = 5;
				else Vx = 7, Vy = 0.3;
			} else if (Up == 0 && Wind == 0) {
				Down = 0;
				Up = 1;
				if (Ren == 2)Map(-1, 0), Vx = 1, X = 10, Map(0, 3), Li = 5;
				else Vx = 2, Vy = 0.1;
			} else if (Up == 1 && Wind == 0) {
				Down = 0;
				Up = 2;
				if (Ren == 2)Map(-1, 0), Vx = 1, X -= 6, Map(0, 3), Li = 5;
				else Vx = 1.5, Vy = 0.1;
			} else if (Ren == 3 && Up == 2 && Wind == 0) {
				Down = 0;
				Up = 3;
				Vx = 1;
				Vy = 0.5;
				Upt = 30;
			} else if (Ren == 4 && Up == 2 && Wind == 0) {
				Down = 0;
				Up = 3;
				Vx = 1.8;
				Vy = 0.1;
			}
		}
		if (GetAsyncKeyState(VK_DOWN) & 0x8000 && u2 == 0) {
			u2++;
			if (Down == 1 && Ren == 5) {
				Down = 2;
				Up = 0;
				Vx = -1.7;
			} else {
				Down = 1;
				Up = 0;
				if (Ren == 2)Map(-1, 0), Vx = 0, X = 22, Map(0, 3), Li = 5;
				else {
					if (Upt != 0) Map(-1, 0), Upt = 0;
					Vx = -7;
				}
			}
		}
		if ((GetAsyncKeyState(VK_UP) & 0x8000) ? 0 : 1) u1 = 0;
		if ((GetAsyncKeyState(VK_DOWN) & 0x8000) ? 0 : 1) u2 = 0;
		if (kbhit()) {
			char g = _getch();
			if (g == ' ') Sleep(100), Setpos(4, 1), Sy++, system("pause");
		}
		if (Sy == 1) Setpos(4, 1), printf("                           "), Sy--;
		if (Drug == 0) Blo = fmin((float)Blomax, Blo + Hui / 100.0);
		else if (T % 10 == 0)Blo--;
		if (T % 20 == 0) {
			if (Kill != 0) Kill = 0;
			if (Lvl != 0) Lvl = 0;
		}
		if (Killb > 0) Killb--;
		if (Li > 0) Li--;
		if (Ice > 0) Ice--;
		if (Drug > 0) Drug--;
		if (Magne > 0) Magne--;
		if (Fire > 0) Ball(1), Fire--;
		if (Water > 0) Ball(2), Water--;
		if (Wind > 0) Ball(3), Wind--;
		if (Thun > 0) Ball(4), Thun--;
		if (Boss == 0) NorGuai(L, T % 1500);
		RandGood();
		if (T % 20 == 1)Exp++;
		if (T % 50 == 1) {
			Exp++;
			system("cls");
			Setpos(20, 0);
			Color(0);
			for (int i = 1; i <= 60; i++) printf("=");
			if (Win == 0 && T < 300) {
				Setpos(4, 6);
				cout << "↑/↓ 跳跃/下翻,←→ 些微移动(松手即返回)";
				Setpos(8, 6);
				cout << "球可以开启特殊效果,经验积满(300)可提升级别。";
				Setpos(8, 6);
				cout << "打败 7 波即胜利,打败 BOSS 有新天赋。";
				Setpos(10, 15);
				cout << "空格可以暂停。";
			}
		}
		Map(-1, 0);
		if (Boss == 1) Boss1();
		if (Boss == 2) Boss2();
		if (Boss == 3) Boss3();
		if (Boss == 6) Boss1(), Boss2(), Boss3();
		Move();
		Map(0, (bool)Kill);
		Color(0);
		Setpos(1, 1);
		Blo = fmin(Blo, (float)Blomax);
		if (Boss == 0)cout << "血量: " << (int)Blo << "  ";
		Color(0);
		Setpos(1, 9), cout << "死亡次数: " << D << "  ";
		Setpos(2, 1);
		Exp = min(Exp, Expmax);
		if (Exp >= Expmax)Exp = 0, Lv++, Lvl++, Hui++, Blomax += 5;
		if (Lvl > 0)Color(5);
		cout << "级别: " << Lv;
		Color(0);
		Setpos(2, 9);
		cout << "经验: " << Exp << "  ";
		if (Boss > 0) Setpos(3, 1), cout << "血量     : ", Ball(7);
		if (Boss > 0 && Boss != 6) Setpos(4, 1), cout << "怪物血量: ", Ball(6);
		if (Boss == 6) Setpos(1, 9), printf("时间: %0.1f s  ", T / 15.0);
		if (Win == 0) Sleep(55);
		if (Win == 1) Sleep(50);
		if (Win == 2) Sleep(35);
		if (Win == 3) Sleep(40);
		if (Win == 4) Sleep(25);
		if (Win == 5) Sleep(30);
		if (Win == 6) Sleep(20);
		if (Win >= 7) Sleep(17);
		if (Boss == 3 && Bblo <= 0) {
			for (int i = 1; i <= 4; i++) {
				br++;
				B[br].what = 98;
				B[br].x = Bx3 - 1, B[br].y = By3 - 1 + i;
				B[br].vy = 4;
				B[br].life = 1;
				br++;
				B[br].what = 98;
				B[br].x = Bx3, B[br].y = By3 - 1 + i;
				B[br].vy = 4;
				B[br].life = 1;
				br++;
				B[br].what = 98;
				B[br].x = Bx3 - 2, B[br].y = By3 - 1 + i;
				B[br].vy = 4;
				B[br].life = 1;
			}
		}
		if ((Win % 2 == 0 && T >= 1400) || (Win % 2 == 1 && Bblo <= 0) || (Win == 7 && T >= 450) || Blo <= 0) {
			Map(-1, 0);
			break;
		}
	}
	if (Blo <= 0) {
		Sleep(1000);
		D++;
		system("color 7F");
		Setpos(15, 11);
		Color(4);
		cout << "GAME OVER...";
		Sleep(2000);
		goto ReStart;
	} else if (Win == 6) {
		system("color 7F");
		Setpos(15, 11);
		Color(4);
		cout << "坚持30秒 !";
		Sleep(2000);
		Setpos(30, 0);
		Win++;
		D = 0;
	} else if (Win == 7) {
		Sleep(1000);
		system("color 6E");
		Setpos(15, 11);
		Color(5);
		cout << "YOU WIN !";
		Sleep(2000);
		Setpos(30, 0);
		return 0;
	} else Sleep(1000), Win++, D = 0;
	goto Start;
}

飞机大战

C++
#include<iostream>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<string>
using namespace std;
 
/*=============== all the structures ===============*/
 
typedef struct Frame
{
	COORD position[2];
	int flag;
}Frame;
 
 
/*=============== all the functions ===============*/
 
void SetPos(COORD a)// set cursor 
{
	HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(out, a);
}
 
void SetPos(int i, int j)// set cursor
{
	COORD pos={i, j};
	SetPos(pos);
}
 
void HideCursor()
{
	CONSOLE_CURSOR_INFO cursor_info = {1, 0}; 
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
 
//把第y行,[x1, x2) 之间的坐标填充为 ch
void drawRow(int y, int x1, int x2, char ch)
{
	SetPos(x1,y);
	for(int i = 0; i <= (x2-x1); i++)
		cout<<ch;
}
 
//在a, b 纵坐标相同的前提下,把坐标 [a, b] 之间填充为 ch
void drawRow(COORD a, COORD b, char ch)
{
	if(a.Y == b.Y)
		drawRow(a.Y, a.X, b.X, ch);
	else
	{
		SetPos(0, 25);
		cout<<"error code 01:无法填充行,因为两个坐标的纵坐标(x)不相等";
		system("pause");
	}
}
 
//把第x列,[y1, y2] 之间的坐标填充为 ch
void drawCol(int x, int y1, int y2, char ch)
{
	int y=y1;
	while(y!=y2+1)
	{
		SetPos(x, y);
		cout<<ch;
		y++;
	}
}
 
//在a, b 横坐标相同的前提下,把坐标 [a, b] 之间填充为 ch
void drawCol(COORD a, COORD b, char ch)
{
	if(a.X == b.X)
		drawCol(a.X, a.Y, b.Y, ch);
	else
	{
		SetPos(0, 25);
		cout<<"error code 02:无法填充列,因为两个坐标的横坐标(y)不相等";
		system("pause");
	}
}
 
//左上角坐标、右下角坐标、用row填充行、用col填充列
void drawFrame(COORD a, COORD  b, char row, char col)
{
	drawRow(a.Y, a.X+1, b.X-1, row);
	drawRow(b.Y, a.X+1, b.X-1, row);
	drawCol(a.X, a.Y+1, b.Y-1, col);
	drawCol(b.X, a.Y+1, b.Y-1, col);
}
 
void drawFrame(int x1, int y1, int x2, int y2, char row, char col)
{
	COORD a={x1, y1};
	COORD b={x2, y2};
	drawFrame(a, b, row, col);
}
 
void drawFrame(Frame frame, char row, char col)
{
	COORD a = frame.position[0];
	COORD b = frame.position[1];
	drawFrame(a, b, row, col);
}
 
void drawPlaying()
{
	drawFrame(0, 0, 48, 24, '=', '|');//    draw map frame;
	drawFrame(49, 0, 79, 4, '-', '|');//        draw output frame
	drawFrame(49, 4, 79, 9, '-', '|');//        draw score frame
	drawFrame(49, 9, 79, 20, '-', '|');//    draw operate frame
	drawFrame(49, 20, 79, 24, '-', '|');//    draw other message frame
	SetPos(52, 6);
	cout<<"得分:";
	SetPos(52, 7);
	cout<<"称号:";
	SetPos(52,10);
	cout<<"操作方式:";
	SetPos(52,12);
	cout<<"  a,s,d,w 控制战机移动。";
	SetPos(52,14);
	cout<<"  p 暂停游戏。";
	SetPos(52,16);
	cout<<"  e 退出游戏。";
}
 
//在[a, b)之间产生一个随机整数
int random(int a, int b)
{
	int c=(rand() % (a-b))+ a;
	return c;
}
 
//在两个坐标包括的矩形框内随机产生一个坐标
COORD random(COORD a, COORD b)
{
	int x=random(a.X, b.X);
	int y=random(a.Y, b.Y);
	COORD c={x, y};
	return c;
}
 
bool  judgeCoordInFrame(Frame frame, COORD spot)
{
	if(spot.X>=frame.position[0].X)
		if(spot.X<=frame.position[1].X)
			if(spot.Y>=frame.position[0].Y)
				if(spot.Y<=frame.position[0].Y)
					return true;
	return false;
}
 
void printCoord(COORD a)
{
	cout    <<"( "<<a.X<<" , "<<a.Y<<" )";
}
 
void printFrameCoord(Frame a)
{
	printCoord(a.position[0]);
	cout    <<" - ";
	printCoord(a.position[1]);
}
 
int drawMenu()
{
	SetPos(30, 1);
	cout<<"P l a n e  W a r";
	drawRow(3, 0, 79, '-');
	drawRow(5, 0, 79, '-');
	SetPos(28, 4);
	cout<<"w 和 s 选择, k 确定";
	SetPos(15, 11);
	cout<<"1. 简单的敌人";
	SetPos(15, 13);
	cout<<"2. 冷酷的敌人";
	drawRow(20, 0, 79, '-');
	drawRow(22, 0, 79, '-');
	SetPos(47, 11);
	cout<<"简单的敌人:";
	SetPos(51, 13);
	cout<<"简单敌人有着较慢的移动速度。";
	SetPos(24, 21);
	cout<<"制作:LJF神犇";
	int j=11;
	SetPos(12, j);
	cout<<">>";
	
	//drawFrame(45, 9, 79, 17, '=', '|');
	
	while(1)
	{    if( _kbhit() )
	{    
		char x=_getch();
		switch (x)
		{
		case 'w' :
			{    
				if( j == 13)
				{
					SetPos(12, j);
					cout<<" ";
					j = 11;
					SetPos(12, j);
					cout<<">>";
					SetPos(51, 13);
					cout<<"            ";
					SetPos(47, 11);
					cout<<"简单的敌人:";
					SetPos(51, 13);
					cout<<"简单敌人有着较慢的移动速度,容易对付。";
				}
				break;
			}
		case 's' :
			{    
				if( j == 11 )
				{
					SetPos(12, j);
					cout<<" ";        
					j = 13;
					SetPos(12, j);
					cout<<">>";
					SetPos(51, 13);
					cout<<"              ";
					SetPos(47, 11);
					cout<<"冷酷的敌人:";
					SetPos(51, 13);
					cout<<"冷酷的敌人移动速度较快,难对付哟!!!";
				}
				break;
			}
		case 'k' :
			{    
				if (j == 8)    return 1;
				else return 2;
			}
		}
	}
	}
}
 
/* 
DWORD WINAPI MusicFun(LPVOID lpParamte)
{
//DWORD OBJ;
sndPlaySound(TEXT("bgm.wav"), SND_FILENAME|SND_ASYNC);
return 0;
}
*/
 
 
/*================== the Game Class ==================*/
 
class Game
{
public:
	COORD position[10];
	COORD bullet[10];
	Frame enemy[8];
	int score;
	int rank;
	int rankf;
	string title;
	int flag_rank;
	
	Game ();
	
	//初始化所有
	void initPlane();
	void initBullet();
	void initEnemy();
	
	//初始化其中一个
	//void initThisBullet( COORD );
	//void initThisEnemy( Frame );
	
	void planeMove(char);
	void bulletMove();
	void enemyMove();
	
	//填充所有
	void drawPlane();
	void drawPlaneToNull();
	void drawBullet();
	void drawBulletToNull();
	void drawEnemy();
	void drawEnemyToNull();
	
	//填充其中一个
	void drawThisBulletToNull( COORD );
	void drawThisEnemyToNull( Frame );
	
	void Pause();
	void Playing();
	void judgePlane();
	void judgeEnemy();
	
	void Shoot();
	
	void GameOver();
	void printScore();
};
 
Game::Game()
{
	initPlane();
	initBullet();
	initEnemy();
	score = 0;
	rank = 25;
	rankf = 0;
	flag_rank = 0;
}
 
void Game::initPlane()
{
	COORD centren={39, 22};
	position[0].X=position[5].X=position[7].X=position[9].X=centren.X;
	position[1].X=centren.X-2;    
	position[2].X=position[6].X=centren.X-1;
	position[3].X=position[8].X=centren.X+1;
	position[4].X=centren.X+2;
	for(int i=0; i<=4; i++)
		position[i].Y=centren.Y;
	for(int i=6; i<=8; i++)
		position[i].Y=centren.Y+1;
	position[5].Y=centren.Y-1;
	position[9].Y=centren.Y-2;
}
 
void Game::drawPlane()
{
	for(int i=0; i<9; i++)
	{
		SetPos(position[i]);
		if(i!=5)
			cout<<"O";
		else if(i==5)
			cout<<"|";        
	}
}
 
void Game::drawPlaneToNull()
{
	for(int i=0; i<9; i++)
	{
		SetPos(position[i]);
		cout<<" ";
	}    
}
 
void Game::initBullet()
{
	for(int i=0; i<10; i++)
		bullet[i].Y = 30;
}
 
void Game::drawBullet()
{
	for(int i=0; i<10; i++)
	{
		if( bullet[i].Y != 30)
		{
			SetPos(bullet[i]);
			cout<<"^";    
		}
	}
}
 
void Game::drawBulletToNull()
{
	for(int i=0; i<10; i++)
		if( bullet[i].Y != 30 )
		{
			COORD pos={bullet[i].X, bullet[i].Y+1};
			SetPos(pos);
			cout<<" ";
		}    
}
 
void Game::initEnemy()
{
	COORD a={1, 1};
	COORD b={45, 15};
	for(int i=0; i<8; i++)
	{
		enemy[i].position[0] = random(a, b);
		enemy[i].position[1].X = enemy[i].position[0].X + 3;
		enemy[i].position[1].Y = enemy[i].position[0].Y + 2;
	}
}
 
void Game::drawEnemy()
{
	for(int i=0; i<8; i++)
		drawFrame(enemy[i].position[0], enemy[i].position[1], '-', '|');
}
 
void Game::drawEnemyToNull()
{
	for(int i=0; i<8; i++)
	{
		drawFrame(enemy[i].position[0], enemy[i].position[1], ' ', ' ');
	}        
}
 
void Game::Pause()
{
	SetPos(61,2);
	cout<<"               ";
	SetPos(61,2);
	cout<<"暂停中...";
	char c=_getch();
	while(c!='p')
		c=_getch();
	SetPos(61,2);
	cout<<"         ";
}
 
void Game::planeMove(char x)
{
	if(x == 'a')
		if(position[1].X != 1)
			for(int i=0; i<=9; i++)
				position[i].X -= 2;
	
	if(x == 's')
		if(position[7].Y != 23)
			for(int i=0; i<=9; i++)
				position[i].Y += 1;
	
	if(x == 'd')
		if(position[4].X != 47)
			for(int i=0; i<=9; i++)
				position[i].X += 2;
	
	if(x == 'w')
		if(position[5].Y != 3)
			for(int i=0; i<=9; i++)
				position[i].Y -= 1;
}
 
void Game::bulletMove()
{
	for(int i=0; i<10; i++)
	{
		if( bullet[i].Y != 30)
		{
			bullet[i].Y -= 1;
			if( bullet[i].Y == 1 )
			{
				COORD pos={bullet[i].X, bullet[i].Y+1};
				drawThisBulletToNull( pos );
				bullet[i].Y=30;
			}
			
		}
	}
}
 
void Game::enemyMove()
{
	for(int i=0; i<8; i++)
	{
		for(int j=0; j<2; j++)
			enemy[i].position[j].Y++;
		
		if(24 == enemy[i].position[1].Y)
		{
			COORD a={1, 1};
			COORD b={45, 3};
			enemy[i].position[0] = random(a, b);
			enemy[i].position[1].X = enemy[i].position[0].X + 3;
			enemy[i].position[1].Y = enemy[i].position[0].Y + 2;
		}
	}
}
 
void Game::judgePlane()
{
	for(int i = 0; i < 8; i++)
		for(int j=0; j<9; j++)
			if(judgeCoordInFrame(enemy[i], position[j]))
			{
				SetPos(62, 1);
				cout<<"坠毁";
				drawFrame(enemy[i], '+', '+');
				Sleep(1000);
				GameOver();
				break;
			}
}
 
void Game::drawThisBulletToNull( COORD c)
{
	SetPos(c);
	cout<<" ";
}
 
void Game::drawThisEnemyToNull( Frame f )
{
	drawFrame(f, ' ', ' ');
}
 
void Game::judgeEnemy()
{
	for(int i = 0; i < 8; i++)
		for(int j = 0; j < 10; j++)
			if( judgeCoordInFrame(enemy[i], bullet[j]) )
			{
				score += 5;
				drawThisEnemyToNull( enemy[i] );
				COORD a={1, 1};
				COORD b={45, 3};
				enemy[i].position[0] = random(a, b);
				enemy[i].position[1].X = enemy[i].position[0].X + 3;
				enemy[i].position[1].Y = enemy[i].position[0].Y + 2;                    
				drawThisBulletToNull( bullet[j] );
				bullet[j].Y = 30;
			}
}
 
void Game::Shoot()
{
	for(int i=0; i<10; i++)
		if(bullet[i].Y == 30)
		{
			bullet[i].X = position[5].X;
			bullet[i].Y = position[5].Y-1;
			break;
		}
}
 
void Game::printScore()
{
	if(score == 120 && flag_rank == 0)
	{
		rank -= 3;
		flag_rank = 1;
	}
	
	else if( score == 360 && flag_rank == 1)
	{
		rank -= 5;
		flag_rank = 2;
	}
	else if( score == 480 && flag_rank == 2)
	{
		rank -= 5;
		flag_rank = 3;
	}
	int x=rank/5;
	SetPos(60, 6);
	cout<<score;
	
	if( rank!=rankf )
	{
		SetPos(60, 7);
		if( x == 5)
			title="初级飞行员";
		else if( x == 4)
			title="中级飞行员";
		else if( x == 3)
			title="高级飞行员";
		else if( x == 2 )
			title="王牌飞行员";
		cout<<title;
	}
	rankf = rank;
}
 
void Game::Playing()
{
	//HANDLE MFUN;
	//MFUN= CreateThread(NULL, 0, MusicFun, NULL, 0, NULL); 
	
	drawEnemy();
	drawPlane();
	
	int flag_bullet = 0;
	int flag_enemy = 0;
	
	while(1)
	{
		Sleep(8);
		if(_kbhit())
		{
			char x = _getch();
			if ('a' == x || 's' == x || 'd' == x || 'w' == x)
			{
				drawPlaneToNull();
				planeMove(x);
				drawPlane();
				judgePlane();
			}            
			else if ('p' == x)
				Pause();
			else if( 'k' == x)
				Shoot();
			else if( 'e' == x)
			{
				//CloseHandle(MFUN);
				GameOver();
				break;
			}
			
		}
		/* 处理子弹 */
		if( 0 == flag_bullet )
		{
			bulletMove();
			drawBulletToNull();
			drawBullet();
			judgeEnemy();
		}            
		flag_bullet++;
		if( 5 == flag_bullet )
			flag_bullet = 0;
		
		/* 处理敌人 */
		if( 0 == flag_enemy )
		{
			drawEnemyToNull();
			enemyMove();            
			drawEnemy();
			judgePlane();
		}
		flag_enemy++;
		if( flag_enemy >= rank )
			flag_enemy = 0;
		
		/* 输出得分 */
		printScore();
	}
}
 
void Game::GameOver()
{
	system("cls");                
	COORD p1={28,9};
	COORD p2={53,15};
	drawFrame(p1, p2, '=', '|');
	SetPos(36,12);
	string str="Game Over!";
	for(int i=0; i<str.size(); i++)
	{
		Sleep(80);
		cout<<str[i];
	}
	Sleep(1000);
	system("cls");
	drawFrame(p1, p2, '=', '|');
	SetPos(31, 11);
	cout<<"击落敌机:"<<score/5<<" 架";
	SetPos(31, 12);
	cout<<"得  分:"<<score;
	SetPos(31, 13);
	cout<<"获得称号:"<<title;
	SetPos(30, 16);
	Sleep(1000);
	cout<<"继续? 是(y)| 否(n)制作:最牛的HJ";
	as:
	char x=_getch();
	if (x == 'n')
		exit(0);
	else if (x == 'y')
	{
		system("cls");
		Game game;
		int a = drawMenu();
		if(a == 2)
			game.rank = 20;
		system("cls");
		drawPlaying();
		game.Playing();
	}
	else goto as;
}
 
/*================== the main function ==================*/
int main()
{
	//游戏准备
	srand((int)time(0));    //随机种子
	HideCursor();    //隐藏光标
	
	Game game;
	int a = drawMenu();
	if(a == 2)
		game.rank = 20;
	system("cls");
	drawPlaying();
	game.Playing();
}

扫雷

C++
#include<bits/stdc++.h>
#include<Windows.h>
#include<conio.h>
using namespace std;
int aaa,bbb,n,m,iy=1,ix=1,mine[100][100]={0},bomb=0,ground=0;
bool dfvis[100][100];
char pass[100][100],an;
int dfs(int dx,int dy){
	int dfsum=0;
	for(int i=-1;i<=1;i++)
		for(int j=-1;j<=1;j++)
			if(mine[dx+i][dy+j]==1)dfsum++;
	pass[dx][dy]=dfsum+'0';
	if(dfsum!=0)return 0;
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			int tx=i+dx;int ty=j+dy;
			if(dfvis[tx][ty]==1||mine[tx][ty]==1||tx>n||tx<1||ty>n||ty<1)continue;
			dfvis[tx][ty]=1;
			ground--;
			dfs(tx,ty);
		}
	}
	return 0;
}
void bb(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			int aa=time(0)*rand()%14+1;
			if(aa<0)aa=aa*-1;
			if(aa<3){
				mine[i][j]=1;
				bomb++;
			}
			else ground++;
		}
	}
}
void qp(){
	system("cls");
}
int main(){
	for(int i=1;i<=99;i++)
		for(int j=1;j<=99;j++)
		pass[i][j]='.';
	cin>>n;
	bb();
	while(1){
	bomb=0;ground=0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(ix==i&&iy==j)cout<<"♀";
				else if(pass[i][j]=='.')cout<<"?";
				else if(pass[i][j]=='0')cout<<"〇";
				else if(pass[i][j]=='1')cout<<"①";
				else if(pass[i][j]=='2')cout<<"②";
				else if(pass[i][j]=='3')cout<<"③";
				else if(pass[i][j]=='4')cout<<"④";
				else if(pass[i][j]=='5')cout<<"⑤";
				else if(pass[i][j]=='6')cout<<"⑥";
				else if(pass[i][j]=='7')cout<<"⑦";
				else if(pass[i][j]=='8')cout<<"⑧";
				else if(pass[i][j]=='b')cout<<"※";
				else cout<<pass[i][j]<<" " ;
				if(pass[i][j]=='.'&&mine[i][j]==1)bomb++;
				if(pass[i][j]=='.'&&mine[i][j]==0)ground++;
			}
			cout<<"\n";
		}cout<<"\n\n"<<ground<<" "<<bomb;
		an=getch();
		qp();
		if(an=='w'&&ix>1)ix--;
		if(an=='s'&&ix<n)ix++;
		if(an=='a'&&iy>1)iy--;
		if(an=='d'&&iy<n)iy++;
		if(an=='h'){
			if(pass[ix][iy]=='.'){
				pass[ix][iy]='b';
				if(mine[ix][iy]=='1')bomb--;
			}
			else if(pass[ix][iy]=='b'){
				pass[ix][iy]='.';
				if(mine[ix][iy]=='1')bomb++;
			}
		}
		if(an=='b'){
			int sum=0;
			if(mine[ix][iy]==1){
				qp();
				for(int i=1;i<=n;i++){
					for(int j=1;j<=n;j++){
						if(pass[i][j]=='b'&&mine[i][j]!=1)cout<<"n ";
						if(pass[i][j]=='.'&&mine[i][j]==1)cout<<"* ";
						else cout<<pass[i][j]<<" ";
					}
					cout<<"\n";
				}
				Sleep(2000);
				return 0;
			}
			else{
				ground--;
			}
            for(int ii=-1;ii<=1;ii++){
                for(int jj=-1;jj<=1;jj++){
                    if(mine[ix+ii][iy+jj]==1)sum++;
                }
            }
            if(sum==0){
            	memset(dfvis,0,sizeof(dfvis));
            	dfs(ix,iy);
			}
            pass[ix][iy]=sum+'0';
		}
		if(bomb==0&&ground==0){
			system("cls");
			cout<<"you win!";
			Sleep(2000);
			system("cls");
			cout<<"you find all mine.";
			Sleep(2000);
			system("cls");
			cout<<"you win!!!!!";
			Sleep(2000);
			return 0;
		}
	}                                              
}

三国杀

C++
#include<iostream>
#include<time.h>
#include<stdio.h>
#include <stdlib.h>
using namespace std;
struct pai {
	int paifu;
	int huase;
	int yanse;
	int dianshu;
	int leixing;
	int changdu;
	void Kanpai() {
		if (paifu == 0 || paifu == 1);
		else
			printf("牌副参数错误!\n");
		switch (huase) {
			case 0:
				cout << "黑桃";
				break;
			case 1:
				cout << "红桃";
				break;
			case 2:
				cout << "草花";
				break;
			case 3:
				cout << "方片";
				break;
			case -1:
				cout << "无色";
				break;
			default:
				printf("花色错误!\n");
				break;
		}
		switch (dianshu) {
			case 0:
				cout << "A ";
				break;
			case 1:
				cout << "2 ";
				break;
			case 2:
				cout << "3 ";
				break;
			case 3:
				cout << "4 ";
				break;
			case 4:
				cout << "5 ";
				break;
			case 5:
				cout << "6 ";
				break;
			case 6:
				cout << "7 ";
				break;
			case 7:
				cout << "8 ";
				break;
			case 8:
				cout << "9 ";
				break;
			case 9:
				cout << "10 ";
				break;
			case 10:
				cout << "J ";
				break;
			case 11:
				cout << "Q ";
				break;
			case 12:
				cout << "K ";
				break;
			case -1:
				cout << "无点数";
				break;
			default:
				printf("点数错误!\n");
				break;
		}
		switch (leixing) {
			case 101:
				cout << "【杀】" << endl;
				break;
			case 102:
				cout << "【闪】" << endl;
				break;
			case 103:
				cout << "【桃】" << endl;
				break;
			case 201:
				cout << "【过河拆桥】" << endl;
				break;
			case 202:
				cout << "【顺手牵羊】" << endl;
				break;
			case 203:
				cout << "【无中生有】" << endl;
				break;
			case 204:
				cout << "【决斗】" << endl;
				break;
			case 205:
				cout << "【借刀杀人】" << endl;
				break;
			case 206:
				cout << "【桃园结义】" << endl;
				break;
			case 207:
				cout << "【五谷丰登】" << endl;
				break;
			case 208:
				cout << "【南蛮入侵】" << endl;
				break;
			case 209:
				cout << "【万箭齐发】" << endl;
				break;
			case 210:
				cout << "【无懈可击】" << endl;
				break;
			case 251:
				cout << "【乐不思蜀】" << endl;
				break;
			case 252:
				cout << "【闪电】" << endl;
				break;
			case 301:
				cout << "【诸葛连弩(1)】" << endl;
				break;
			case 302:
				cout << "【雌雄双股剑(2)】" << endl;
				break;
			case 303:
				cout << "【青釭剑(2)】" << endl;
				break;
			case 304:
				cout << "【青龙偃月刀(3)】" << endl;
				break;
			case 305:
				cout << "【丈八蛇矛(3)】" << endl;
				break;
			case 306:
				cout << "【贯石斧(3)】" << endl;
				break;
			case 307:
				cout << "【方天画戟(4)】" << endl;
				break;
			case 308:
				cout << "【麒麟弓(5)】" << endl;
				break;
			case 331:
				cout << "【八卦阵】" << endl;
				break;
			case 361:
				cout << "【赤兔(-1)】" << endl;
				break;
			case 362:
				cout << "【大宛(-1)】" << endl;
				break;
			case 363:
				cout << "【紫辛(-1)】" << endl;
				break;
			case 381:
				cout << "【爪黄飞电(+1)】" << endl;
				break;
			case 382:
				cout << "【的卢(+1)】" << endl;
				break;
			case 383:
				cout << "【绝影(+1)】" << endl;
				break;
			default:
				printf("类型参数错误!");
				break;
		}
	}
};
void Qishixipai(pai A[2][4][13], pai paidui[104]) {
	int i, m, x, y, z, a[104] = {0};
	srand((unsigned)time(NULL));
	for (i = 1; i <= 104; i++) {
		while (a[m = rand() % 104]);
		a[m] = i;
	}
	for (i = 0; i <= 103; i++) {
		x = (a[i] - 1) / 52;
		y = ((a[i] - 1) - 52 * x) / 13;
		z = (a[i] - 1) % 13;
		paidui[i] = A[x][y][z];
	}
}
void Xipai(pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
	int i, m, a[104] = {0};
	srand((unsigned)time(NULL));
	for (i = 1; i <= (*qipaishu); i++) {
		while (a[m = rand() % (*qipaishu)]);
		a[m] = i;
	}
	for (i = 0; i <= ((*qipaishu) - 1); i++) {
		paidui[i] = qipaidui[a[i]];
		qipaidui[a[i]].leixing = -1;
		(*paiduishu)++;
		(*qipaishu)--;
	}
	for (i = (*paiduishu); i <= 103; i++)paidui[i].leixing = -1;
}
pai Mo1pai(pai A[104], int *x, pai B[104], int*y, int *b) {
	pai p;
	if ((*x) == 0)Xipai(A, x, B, y);
	else if ((*x) < 0)printf("摸牌参数错误!");
	else;
	p = A[104 - (*x)];
	(*x)--;
	(*b)++;
	return (p);
}
struct wujiang {
	char name;
	int tili;
	int tilishangxian;
	int shoupaishangxian;
	int huihekaishi;
	int panding;
	int mopai;
	int chupai;
	int qipai;
	int huihejieshu;
	int juese;
	pai shoupai[20];
	int shoupaishu;
	pai zhuangbei[4];
	int zhuangbeishu;
	pai pandingpai[3];
	int pandingshu;
	int juli[1];
	void Kanshoupai() {
		printf("玩家当前手牌:\n");
		if (shoupaishu) {
			int m;
			for (m = 0; m <= (shoupaishu - 1); m++) {
				printf("%d ", m);
				(shoupai[m]).Kanpai();
			}
		} else printf("空城!\n");
		printf("\n");
	}
	void Kanzhuangbei() {
		if (juese)printf("玩家");
		else printf("电脑");
		printf("当前装备:\n");
		printf("0 武器: ");
		if ((zhuangbei[0]).leixing == -1)printf("空\n");
		else (zhuangbei[0]).Kanpai();
		printf("1 防具: ");
		if ((zhuangbei[1]).leixing == -1)printf("空\n");
		else (zhuangbei[1]).Kanpai();
		printf("2 进攻马: ");
		if ((zhuangbei[2]).leixing == -1)printf("空\n");
		else (zhuangbei[2]).Kanpai();
		printf("3 防御马: ");
		if ((zhuangbei[3]).leixing == -1)printf("空\n");
		else (zhuangbei[3]).Kanpai();
		printf("\n");
	}
	void Kanpandingpai() {
		if (juese)printf("玩家");
		else printf("电脑");
		printf("当前判定区:\n");
		if ((pandingpai[0]).leixing == -1)printf("空\n");
		else {
			printf("0 ");
			(pandingpai[0]).Kanpai();
			if ((pandingpai[1]).leixing == -1);
			else {
				printf("1 ");
				(pandingpai[1]).Kanpai();
				if ((pandingpai[2]).leixing == -1);
				else {
					printf("2 ");
					(pandingpai[2]).Kanpai();
				}
			}
		}
	}
};
void Mopai(int*shoupaishu, pai shoupai[20], pai A[104], int *x, pai B[104], int*y, int juese) {
	if (juese)printf("玩家从牌堆摸2张牌\n");
	else printf("电脑从牌堆摸2张牌\n");
	pai p;
	p = Mo1pai(A, x, B, y, shoupaishu);
	shoupai[*shoupaishu - 1] = p;
	pai q;
	q = Mo1pai(A, x, B, y, shoupaishu);
	shoupai[*shoupaishu - 1] = q;
	int m;
	if (juese) {
		printf("玩家当前手牌:\n");
		for (m = 0; m <= (*shoupaishu - 1); m++) {
			printf("%d ", m);
			(shoupai[m]).Kanpai();
		}
	}
	printf("牌堆还剩%d张牌!\n\n", *x);
}
void Qishishoupai(wujiang *w, pai A[104], int *x, pai B[104], int*y) {
	pai a;
	a = Mo1pai(A, x, B, y, &((*w).shoupaishu));
	(*w).shoupai[(*w).shoupaishu - 1] = a;
	pai b;
	b = Mo1pai(A, x, B, y, &((*w).shoupaishu));
	(*w).shoupai[(*w).shoupaishu - 1] = b;
	pai c;
	c = Mo1pai(A, x, B, y, &((*w).shoupaishu));
	(*w).shoupai[(*w).shoupaishu - 1] = c;
	pai d;
	d = Mo1pai(A, x, B, y, &((*w).shoupaishu));
	(*w).shoupai[(*w).shoupaishu - 1] = d;
	int m;
	if ((*w).juese)printf("玩家从牌堆摸4张牌\n");
	else printf("电脑从牌堆摸4张牌\n");
	if ((*w).juese) {
		printf("玩家当前手牌:\n");
		for (m = 0; m <= ((*w).shoupaishu - 1); m++) {
			printf("%d ", m);
			((*w).shoupai[m]).Kanpai();
		}
	}
	printf("牌堆还剩%d张牌!\n\n", *x);
}
void Panding(pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
	paidui[*paiduishu].Kanpai();
	qipaidui[*qipaishu] = paidui[*paiduishu];
	(*paiduishu)--;
	(*qipaishu)++;
}
pai Zhangba(wujiang*w, pai qipaidui[104], int*qipaishu) {
	int x, y;
	pai p;
	for (;;) {
		int i, j;
		printf("请输入任意两张手牌之前的编号,以空格隔开,以回车结束!\n");
		scanf("%d", &x);
		scanf("%d", &y);
		if ((x >= 0) && (x < (*w).shoupaishu) && (y >= 0) && (y < (*w).shoupaishu - 1)) {
			switch ((((*w).shoupai[x].huase) % 2) + (((*w).shoupai[y].huase) % 2)) {
				case 0:
					p.yanse = 0;
					break;
				case 2:
					p.yanse = 1;
					break;
				case 1:
					p.yanse = 2;
					break;
				default:
					printf("【丈八蛇矛】函数参数错误!\n");
			}
			qipaidui[*qipaishu] = (*w).shoupai[x];
			(*w).shoupai[x].leixing = -1;
			((*w).shoupaishu)--;
			(*qipaishu)++;
			qipaidui[*qipaishu] = (*w).shoupai[y];
			(*w).shoupai[y].leixing = -1;
			((*w).shoupaishu)--;
			(*qipaishu)++;
			printf("弃牌数:%d", *qipaishu);
			for (i = 0; i <= (((*w).shoupaishu) + 1); i++) {
				if ((*w).shoupai[i].leixing == -1) {
					for (j = i + 1; j <= (((*w).shoupaishu) + 2); j++)
						(*w).shoupai[j - 1] = (*w).shoupai[j];
					i--;
				}
			}
			printf("玩家把:\n");
			qipaidui[(*qipaishu) - 2].Kanpai();
			qipaidui[(*qipaishu) - 1].Kanpai();
			printf("当作一张");
			switch (p.yanse) {
				case 0:
					printf("黑色");
					break;
				case 2:
					printf("红色");
					break;
				case 1:
					printf("无色");
					break;
				default:
					printf("绿色");
					break;
			}
			printf("无点数的【杀】");
			p.dianshu = -1;
			p.leixing = 101;
			return p;
			break;
		}
		printf("你将两张空气当作一张空气属性的【杀】使用或打出!\n");
	}
}
int Xuanpai(wujiang*w, int t) {
	int x;
	if ((*w).juese) {
		for (;;) {
			printf("出牌请输入手牌之前的编号,以回车结束!\n如果你想结束出牌阶段,请输入“-1”,以回车结束!\n");
			scanf("%d", &x);
			if ((x >= -1 && x < ((*w).shoupaishu)) || ((x == 100) && ((*w).zhuangbei[0].leixing == 305))) {
				return x;
				break;
			}
			printf("你打出了一张空气!\n");
		}
	} else return t;
}
pai Panpai(wujiang*w1, int*sha, int y, pai qipaidui[104], int*qipaishu) {
	pai p, q;
	p.leixing = 0;
	q.leixing = -1;
	if (y == -1)return q;
	else {
		if (y == 100) {
			if ((*sha) > 0) {
				q = Zhangba(w1, qipaidui, qipaishu);
				printf("使用!\n");
				return q;
			} else {
				printf("当前回合使用【杀】的次数已用尽,你也不能使用【丈八蛇矛】效果!\n");
				return p;
			}
		}
		switch ((*w1).shoupai[y].leixing) {
			case 101:
				if (((*sha) > 0) || ((*w1).zhuangbei[0].leixing == 301)) {
					if (((*w1).zhuangbei[0].leixing == 301))printf("武器【诸葛连弩】效果被触发!\n");
					return (*w1).shoupai[y];
					break;
				} else {
					if ((*w1).juese)printf("当前回合使用【杀】的次数已用尽,你不能使用【杀】!\n");
					return p;
					break;
				}
			case 102:
				if ((*w1).juese)
					printf("当前不需要响应任何操作,你不能主动打出【闪】!\n");
				return p;
				break;
			case 103:
				if (((*w1).tili) < ((*w1).tilishangxian)) {
					return (*w1).shoupai[y];
					break;
				} else {
					if ((*w1).juese)
						printf("你并未受伤,不能对自己使用【桃】!\n");
				}
				return p;
				break;
			case 210:
				if ((*w1).juese)
					printf("当前不需要响应任何锦囊,你不能主动打出【无懈可击】!\n");
				return p;
				break;
			case 201:
			case 202:
			case 203:
			case 204:
			case 205:
			case 206:
			case 207:
			case 208:
			case 209:
			case 251:
			case 252:
			case 301:
			case 302:
			case 303:
			case 304:
			case 305:
			case 306:
			case 307:
			case 308:
			case 331:
			case 361:
			case 362:
			case 363:
			case 381:
			case 382:
			case 383:
				return (*w1).shoupai[y];
				break;
			default:
				printf("手牌类型参数错误!\n");
				return p;
				break;
		}
	}
}
int Mubiao(pai p, wujiang *w1, wujiang *w2, int*sha) {
	int x;
	switch (p.leixing) {
		case 101:
			if ((*w1).juese) {
				printf("请选择【杀】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
				scanf("%d", &x);
				if (x == 0) {
					if ((*w1).zhuangbei[0].changdu >= (*w1).juli[0]) {
						(*sha)--;
						return ((*w2).juese);
					} else {
						printf("武器长度不够!\n");
						return -2;
					}
				} else {
					printf("目标错误!\n");
					return -2;
				}
			} else {
				if ((*w1).zhuangbei[0].changdu >= (*w1).juli[0]) {
					(*sha)--;
					return ((*w2).juese);
				} else return -2;
			}
			break;
		case 103:
			return ((*w1).juese);
			break;
		case 201:
			if ((*w1).juese) {
				printf("请选择【过河拆桥】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
				scanf("%d", &x);
				if (x == 0) {
					if ((*w2).shoupaishu || (*w2).zhuangbeishu || (*w2).pandingshu)return ((*w2).juese);
					else {
						printf("目标没有牌!\n");
						return -2;
					}
				} else {
					printf("目标错误!\n");
					return -2;
				}
			} else return ((*w2).juese);
			break;
		case 202:
			if ((*w1).juese) {
				printf("请选择【顺手牵羊】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
				scanf("%d", &x);
				if (x == 0) {
					if (((*w2).shoupaishu || (*w2).zhuangbeishu || (*w2).pandingshu) && ((*w1).juli[0] <= 1))return ((*w2).juese);
					else {
						printf("目标没有牌!\n");
						return -2;
					}
				} else {
					printf("目标错误!\n");
					return -2;
				}
			} else {
				if ((*w1).juli[0] <= 1)return ((*w2).juese);
				else return -2;
			}
			break;
		case 203:
			return ((*w1).juese);
			break;
		case 204:
			if ((*w1).juese) {
				printf("请选择【决斗】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
				scanf("%d", &x);
				if (x == 0)return ((*w2).juese);
				else {
					printf("目标错误!\n");
					return -2;
				}
			} else return ((*w2).juese);
			break;
		case 205:
			int y;
			if ((*w1).juese) {
				printf("请选择【借刀杀人】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
				scanf("%d", &x);
				if (x != 0) {
					printf("目标错误!\n");
					return -2;
				} else {
					if (((*w2).zhuangbei[0]).leixing <= 300 || ((*w2).zhuangbei[0]).leixing >= 331) {
						printf("目标装备区里没有武器!\n");
						return -2;
					} else {
						printf("请选择【杀】的目标!\n提示:【杀】的目标必须在【借刀杀人】的目标的攻击范围之内!\n输入目标前的编号,以回车结束!\n0 玩家\n");
						scanf("%d", &y);
						if (y != 0) {
							printf("目标错误!\n");
							return -2;
						} else {
							if (((*w2).zhuangbei[0].changdu) < (*w2).juli[0]) {
								printf("武器距离不够!\n");
								return -2;
							} else
								return ((*w2).juese);
						}
					}
				}
			} else {
				if (((*w2).zhuangbei[0]).leixing <= 300 || ((*w2).zhuangbei[0]).leixing >= 331)return -2;
				else {
					if (((*w2).zhuangbei[0].changdu) < (*w2).juli[0])return -2;
					else return ((*w2).juese);
				}
			}
			break;
		case 206:
		case 207:
			return 99;
			break;
		case 208:
		case 209:
			return 100;
			break;
		case 251:
			if ((*w1).juese) {
				printf("请选择【乐不思蜀】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
				scanf("%d", &x);
				if (x == 0) {
					int i;
					for (i = 0; i <= 2; i++) {
						if ((*w2).pandingpai[i].leixing == 251)
							i = -1;
						break;
					}
					if (i == -1) {
						printf("目标判定区里不能同时存在两张相同的延时类锦囊!\n");
						return -2;
					} else return ((*w2).juese);
				} else {
					printf("目标错误!\n");
					return -2;
				}
			} else {
				int i;
				for (i = 0; i <= 2; i++) {
					if ((*w2).pandingpai[i].leixing == 251)
						i = -1;
					break;
				}
				if (i == -1)return -2;
				else return ((*w2).juese);
			}
			break;
		case 252:
			int i;
			for (i = 0; i <= 2; i++) {
				if ((*w1).pandingpai[i].leixing == 252)
					i = -1;
				break;
			}
			if (i == -1) {
				if ((*w1).juese)printf("目标判定区里不能同时存在两张相同的延时类锦囊!\n");
				return -2;
			} else return ((*w1).juese);
			break;
		case 301:
		case 302:
		case 303:
		case 304:
		case 305:
		case 306:
		case 307:
		case 308:
		case 331:
		case 361:
		case 362:
		case 363:
		case 381:
		case 382:
		case 383:
			return ((*w1).juese);
			break;
		default:
			return -2;
			break;
	}
}
void Da1pai(wujiang *w1, wujiang*w2, pai qipaidui[104], int *qipaishu, int x) {
	int i;
	if ((x < 0 || x >= ((*w1).shoupaishu)) && x != 100)
		printf("你的牌呢?!\n");
	else {
		switch (((*w1).shoupai)[x].leixing) {
			case 101:
			case 102:
			case 103:
			case 201:
			case 202:
			case 203:
			case 204:
			case 205:
			case 206:
			case 207:
			case 208:
			case 209:
			case 210:
				qipaidui[*qipaishu] = ((*w1).shoupai)[x];
				for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
				((*w1).shoupaishu)--;
				(*qipaishu)++;
				break;
			case 251:
				for (i = 1; i >= 0; i--)(*w2).pandingpai[i + 1] = (*w2).pandingpai[i];
				(*w2).pandingpai[0] = (*w1).shoupai[x];
				for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
				((*w1).shoupaishu)--;
				((*w2).pandingshu)++;
				break;
			case 252:
				for (i = 1; i >= 0; i--)(*w1).pandingpai[i + 1] = (*w1).pandingpai[i];
				(*w1).pandingpai[0] = (*w1).shoupai[x];
				for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
				((*w1).shoupaishu)--;
				((*w1).pandingshu)++;
				break;
			case 301:
			case 302:
			case 303:
			case 304:
			case 305:
			case 306:
			case 307:
			case 308:
				if ((*w1).zhuangbei[0].leixing == -1)((*w1).zhuangbeishu)++;
				else {
					qipaidui[*qipaishu] = ((*w1).zhuangbei)[0];
					(*qipaishu)++;
				}
				(*w1).zhuangbei[0] = (*w1).shoupai[x];
				for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
				((*w1).shoupaishu)--;
				break;
			case 331:
				if ((*w1).zhuangbei[1].leixing == -1)((*w1).zhuangbeishu)++;
				else {
					qipaidui[*qipaishu] = ((*w1).zhuangbei)[1];
					(*qipaishu)++;
				}
				(*w1).zhuangbei[1] = (*w1).shoupai[x];
				for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
				((*w1).shoupaishu)--;
				break;
			case 361:
			case 362:
			case 363:
				if ((*w1).zhuangbei[2].leixing == -1)((*w1).zhuangbeishu)++;
				else {
					qipaidui[*qipaishu] = ((*w1).zhuangbei)[2];
					(*qipaishu)++;
				}
				(*w1).zhuangbei[2] = (*w1).shoupai[x];
				for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
				((*w1).shoupaishu)--;
				break;
			case 381:
			case 382:
			case 383:
				if ((*w1).zhuangbei[3].leixing == -1)((*w1).zhuangbeishu)++;
				else {
					qipaidui[*qipaishu] = ((*w1).zhuangbei)[3];
					(*qipaishu)++;
				}
				(*w1).zhuangbei[3] = (*w1).shoupai[x];
				for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
				((*w1).shoupaishu)--;
				break;
			default:
				break;
		}
	}
}
void Miaoshu(pai p, int juese, int duixiang) {
	if (juese == 0)printf("电脑");
	else if (juese == 1)printf("玩家");
	else printf("角色参数错误!\n");
	if (p.leixing <= 300 && p.leixing > 100) {
		switch (duixiang) {
			case -1:
				printf("打出");
				break;
			case 0:
				printf("对电脑使用");
				break;
			case 1:
				printf("对玩家使用");
				break;
			case 99:
				printf("使用");
				break;
			case 100:
				printf("对所有人使用");
				break;
			default:
				printf("对象参数错误\n");
				break;
		}
	} else if (p.leixing >= 301 && p.leixing <= 400)
		printf("装备");
	else printf("你出的是什么东西?\n");
	p.Kanpai();
	if (!juese && (p.leixing == 101 || p.leixing == 204 || p.leixing == 205 || p.leixing == 207 || p.leixing == 208 || p.leixing == 209))printf("请响应!\n");
}
int Wuxie(pai *p, wujiang*w1, wujiang*w2, pai qipaidui[104], int*qipaishu, int a) {
	int x;
	if ((*w1).juese) {
		printf("是否使用【无懈可击】响应?\n\n");
		for (;;) {
			(*w1).Kanshoupai();
			printf("如果要使用【无懈可击】请输入手牌之前编号,不需要请输入“-1”,以回车结束!\n");
			scanf("%d", &x);
			if (x == -1) {
				for (x = 0; x < ((*w2).shoupaishu); x++) {
					if ((*w2).shoupai[x].leixing == 210) {
						printf("电脑使用");
						((*w2).shoupai)[x].Kanpai();
						printf("对象是");
						(*p).Kanpai();
						(*p) = ((*w2).shoupai)[x];
						qipaidui[*qipaishu] = ((*w2).shoupai)[x];
						for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
						((*w2).shoupaishu)--;
						(*qipaishu)++;
						a++;
						break;
					}
				}
				break;
			} else if ((*w1).shoupai[x].leixing == 210) {
				printf("玩家使用");
				((*w1).shoupai)[x].Kanpai();
				printf("对象是");
				(*p).Kanpai();
				(*p) = ((*w1).shoupai)[x];
				qipaidui[*qipaishu] = ((*w1).shoupai)[x];
				for (int i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
				((*w1).shoupaishu)--;
				(*qipaishu)++;
				(*w1).Kanshoupai();
				a++;
				break;
			} else printf("你确定你使用的是【无懈可击】?\n");
		}
	} else {
		printf("是否使用【无懈可击】响应?\n");
		for (;;) {
			(*w2).Kanshoupai();
			printf("如果要使用【无懈可击】请输入手牌之前编号,不需要请输入“-1”,以回车结束!\n");
			scanf("%d", &x);
			if (x == -1)break;
			else if ((*w2).shoupai[x].leixing == 210) {
				printf("玩家使用");
				((*w2).shoupai)[x].Kanpai();
				printf("对象是");
				(*p).Kanpai();
				(*p) = ((*w2).shoupai)[x];
				qipaidui[*qipaishu] = ((*w2).shoupai)[x];
				for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
				((*w2).shoupaishu)--;
				(*qipaishu)++;
				(*w2).Kanshoupai();
				a++;
				break;
			} else printf("你确定你使用的是【无懈可击】?\n");
		}
	}
	return a;
}
int Qiutao(wujiang*w, pai qipaidui[104], int*qipaishu) {
	int x;
	if ((*w).juese) {
		for (;;) {
			printf("如果要使用【桃】请输入手牌之前的编号,不需要请输入“-1”,以回车结束!\n");
			scanf("%d", &x);
			if (x == -1) {
				return -1;
				break;
			} else if ((*w).shoupai[x].leixing == 103) {
				qipaidui[*qipaishu] = ((*w).shoupai)[x];
				for (int i = x + 1; i <= ((*w).shoupaishu); i++)((*w).shoupai)[i - 1] = ((*w).shoupai)[i];
				((*w).shoupaishu)--;
				(*qipaishu)++;
				return 0;
				break;
			} else printf("你确定你使用的是【桃】?\n");
		}
	} else {
		for (x = 0; x < ((*w).shoupaishu); x++) {
			if ((*w).shoupai[x].leixing == 103) {
				qipaidui[*qipaishu] = ((*w).shoupai)[x];
				for (int i = x + 1; i <= ((*w).shoupaishu); i++)((*w).shoupai)[i - 1] = ((*w).shoupai)[i];
				((*w).shoupaishu)--;
				(*qipaishu)++;
				return 0;
				break;
			}
		}
		return -1;
	}
}
int Binsi(wujiang*w1, wujiang*w2, pai qipaidui[104], int*qipaishu) {
	if (((*w2).tili) > 0)return 0;
	else {
		int i;
		if ((*w1).juese) {
			for (;;) {
				printf("电脑濒死,是否使用【桃】?\n");
				i = Qiutao(w1, qipaidui, qipaishu);
				if (i == 0)((*w2).tili)++;
				if ((i == -1) || ((*w2).tili > 0))break;
			}
			if ((*w2).tili > 0)return 0;
			else {
				for (;;) {
					i = Qiutao(w2, qipaidui, qipaishu);
					if (i == 0)((*w2).tili)++;
					if ((i == -1) || ((*w2).tili > 0))break;
				}
				if ((*w2).tili > 0)return 0;
				else return -1;
			}
		} else {
			for (;;) {
				printf("玩家濒死,是否使用【桃】?\n");
				i = Qiutao(w2, qipaidui, qipaishu);
				if (i == 0)((*w2).tili)++;
				if ((i == -1) || ((*w2).tili > 0))break;
			}
			if ((*w2).tili > 0)return 0;
			else return -1;
		}
	}
}
int Shan(wujiang*w1, wujiang*w2, pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
	int x;
	if ((*w2).juese) {
		if (((*w2).zhuangbei[1].leixing == 331) && ((*w1).zhuangbei[0].leixing != 303)) {
			for (;;) {
				int m;
				printf("是否发动【八卦阵】防具效果?\n0 否\n1 是\n请输入选项之前的编号,以回车结束!\n");
				scanf("%d", &m);
				if (m == 1) {
					Panding(paidui, paiduishu, qipaidui, qipaishu);
					if (qipaidui[(*qipaishu) - 1].huase % 2) {
						printf("【八卦阵】判定成功!\n");
						return 0;
					}
				} else if (m == 0) {
					printf("【八卦阵】判定失败!\n");
					break;
				} else printf("你确定你输入的是“0”或“1”?\n");
			}
		} else if (((*w2).zhuangbei[1].leixing == 331) && ((*w1).zhuangbei[0].leixing == 303))printf("【青釭剑】锁定技被触发!\n");
		for (;;) {
			printf("请输入手牌之前的编号,或者输入“-1”放弃打出【闪】,以回车结束!\n");
			scanf("%d", &x);
			if (x == -1) {
				return -1;
				break;
			} else if ((*w2).shoupai[x].leixing == 102) {
				printf("玩家打出");
				((*w2).shoupai)[x].Kanpai();
				qipaidui[*qipaishu] = ((*w2).shoupai)[x];
				for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
				((*w2).shoupaishu)--;
				(*qipaishu)++;
				return 0;
				break;
			} else printf("你确定你打出的是【闪】?\n");
		}
	} else {
		if (((*w2).zhuangbei[1].leixing == 331) && ((*w1).zhuangbei[0].leixing != 303)) {
			Panding(paidui, paiduishu, qipaidui, qipaishu);
			if (qipaidui[(*qipaishu) - 1].huase % 2) {
				printf("【八卦阵】判定成功!\n");
				return 0;
			} else printf("【八卦阵】判定失败!\n");
		} else if (((*w2).zhuangbei[1].leixing == 331) && ((*w1).zhuangbei[0].leixing == 303))printf("【青釭剑】锁定技被触发!\n");
		int i;
		for (x = 0; x < ((*w2).shoupaishu); x++) {
			if ((*w2).shoupai[x].leixing == 102) {
				printf("电脑打出");
				((*w2).shoupai)[x].Kanpai();
				qipaidui[*qipaishu] = ((*w2).shoupai)[x];
				for (i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
				((*w2).shoupaishu)--;
				(*qipaishu)++;
				return 0;
				break;
			}
		}
		return -1;
	}
}
int Sha(wujiang *w1, wujiang*w2, pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
	int x;
	if ((*w2).juese) {
		printf("请打出【闪】响应【杀】!否则你将受到1点伤害!\n");
		x = Shan(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
		if (x == -1) {
			int i;
			((*w2).tili)--;
			printf("电脑对玩家造成1点伤害!\n");
			i = Binsi(w1, w2, qipaidui, qipaishu);
			return i;
		} else if (x == 0 && ((*w1).zhuangbei[0].leixing == 306)) {
			int i;
			if (((*w1).shoupaishu) >= 2) {
				printf("电脑弃掉:\n");
				((*w1).shoupai)[0].Kanpai();
				qipaidui[*qipaishu] = ((*w1).shoupai)[0];
				for (i = 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
				((*w1).shoupaishu)--;
				(*qipaishu)++;
				((*w1).shoupai)[0].Kanpai();
				qipaidui[*qipaishu] = ((*w1).shoupai)[0];
				for (i = 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
				((*w1).shoupaishu)--;
				(*qipaishu)++;
				printf("发动【贯石斧】武器效果使【杀】造成伤害!\n");
				((*w2).tili)--;
				i = Binsi(w1, w2, qipaidui, qipaishu);
				return i;
			} else return 0;
		} else if (x == 0 && ((*w1).zhuangbei[0].leixing == 304)) {
			int i;
			for (x = 0; x < ((*w1).shoupaishu); x++) {
				if ((*w1).shoupai[x].leixing == 101) {
					printf("电脑发动【青龙偃月刀】效果对玩家使用");
					((*w1).shoupai)[x].Kanpai();
					qipaidui[*qipaishu] = ((*w1).shoupai)[x];
					for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
					((*w1).shoupaishu)--;
					(*qipaishu)++;
					i = Sha(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
					return i;
					break;
				}
			}
			return 0;
		}
	} else {
		x = Shan(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
		if (x == -1) {
			if ((*w1).zhuangbei[0].leixing == 308) {
				for (;;) {
					printf("是否发动【麒麟弓】武器效果?\n0 否\n1 是\n");
					scanf("%d", &x);
					if (x == 1) {
						if (((*w2).zhuangbei[2].leixing == -1) && ((*w2).zhuangbei[3].leixing == -1)) {
							printf("电脑根本没有马,射你妹的马啊!\n");
							break;
						} else {
							for (;;) {
								printf("0 ");
								((*w2).zhuangbei[2]).Kanpai();
								printf("1 ");
								((*w2).zhuangbei[3]).Kanpai();
								printf("请选择要弃掉的马,输入之前的编号,以回车结束!\n");
								scanf("%d", &x);
								if ((x == 0) && ((*w2).zhuangbei[2].leixing != -1)) {
									printf("你弃掉了电脑的");
									((*w2).zhuangbei)[2].Kanpai();
									qipaidui[*qipaishu] = ((*w2).zhuangbei)[2];
									((*w2).zhuangbeishu)--;
									(*qipaishu)++;
									((*w2).zhuangbei)[2].leixing = -1;
									((*w2).juli[0])++;
									break;
								} else if ((x == 1) && ((*w2).zhuangbei[3].leixing != -1)) {
									printf("你弃掉了电脑的");
									((*w2).zhuangbei)[3].Kanpai();
									qipaidui[*qipaishu] = ((*w2).zhuangbei)[3];
									((*w2).zhuangbeishu)--;
									(*qipaishu)++;
									((*w2).zhuangbei)[3].leixing = -1;
									((*w1).juli[0])--;
									break;
								} else printf("射你妹的马!");
							}
							break;
						}
					} else if (x == 0)break;
					else printf("键盘上的“0”和“1”被你吃了吗?\n");
				}
			}
			int i;
			((*w2).tili)--;
			printf("玩家对电脑造成1点伤害!\n");
			i = Binsi(w1, w2, qipaidui, qipaishu);
			return i;
		} else if (x == 0 && ((*w1).zhuangbei[0].leixing == 306)) {
			for (;;) {
				printf("是否发动【贯石斧】武器效果?\n0 否\n1 是\n");
				scanf("%d", &x);
				if (x == 1) {
					int i;
					if ((*w1).shoupaishu + (*w1).zhuangbeishu <= 2) {
						printf("你除了【贯石斧】以外连2张牌都没有,发动你妹的效果!\n");
						break;
					} else {
						printf("请分别弃掉两张牌!\n");
						for (i = 0; i <= 2; i++) {
							for (;;) {
								printf("请选择区域:\n0 手牌\n1 装备\n");
								scanf("%d", &x);
								if (x == 0 && ((*w1).shoupaishu == 0))printf("你根本没有手牌,弃你妹啊!\n");
								else if (x == 1 && ((*w1).zhuangbeishu == 1))printf("你根本没有别的装备,弃你妹啊!\n");
								else if (x >= 0 && x <= 1)break;
								else printf("键盘上的“0”和“1”被你吃了吗?\n");
							}
							if (x == 0) {
								for (;;) {
									(*w1).Kanshoupai();
									printf("弃牌请输入手牌之前的编号,以回车结束!\n");
									scanf("%d", &x);
									if (x >= 0 && x < ((*w1).shoupaishu))break;
									else printf("弃你妹的手牌!\n");
								}
								printf("你弃掉了");
								((*w1).shoupai)[x].Kanpai();
								qipaidui[*qipaishu] = ((*w1).shoupai)[x];
								for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
								((*w1).shoupaishu)--;
								(*qipaishu)++;
							} else {
								for (;;) {
									(*w1).Kanzhuangbei();
									printf("请输入装备之前的编号,以回车键结束!\n");
									scanf("%d", &x);
									if ((((*w1).zhuangbei[x]).leixing != -1) && (x >= 0) && (x <= 3)) {
										printf("你弃掉了");
										((*w1).zhuangbei)[x].Kanpai();
										qipaidui[*qipaishu] = ((*w1).zhuangbei)[x];
										((*w1).zhuangbeishu)--;
										(*qipaishu)++;
										((*w1).zhuangbei)[x].leixing = -1;
										break;
									} else printf("弃你妹的装备!\n");
								}
							}
						}
					}
					printf("玩家发动【贯石斧】武器效果使【杀】造成伤害!\n");
					((*w2).tili)--;
					i = Binsi(w1, w2, qipaidui, qipaishu);
					return i;
					break;
				} else if (x == 0)break;
				else printf("键盘上的“0”和“1”被你吃了吗?\n");
			}
		} else if (x == 0 && ((*w1).zhuangbei[0].leixing == 304)) {
			for (;;) {
				printf("是否发动【青龙偃月刀】武器效果?\n0 否\n1 是\n");
				scanf("%d", &x);
				if (x == 1) {
					for (;;) {
						printf("请对电脑使用一张【杀】!\n请输入手牌之前的编号,或者输入“-1”放弃出【杀】,以回车结束!\n");
						(*w1).Kanshoupai();
						scanf("%d", &x);
						if (x == -1) {
							return 0;
							break;
						} else if ((*w1).shoupai[x].leixing == 101) {
							int i;
							printf("玩家对电脑使用");
							((*w1).shoupai)[x].Kanpai();
							qipaidui[*qipaishu] = ((*w1).shoupai)[x];
							for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
							((*w1).shoupaishu)--;
							(*qipaishu)++;
							i = Sha(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
							return i;
							break;
						} else printf("你确定你打出的是【杀】?\n");
					}
				} else if (x == 0) {
					return 0;
					break;
				} else printf("你确定你输入的是“0”或“1”?\n");
			}
		} else return 0;
	}
	return 0;
}
void Tao(wujiang*w1) {
	((*w1).tili)++;
	if ((*w1).juese)printf("玩家");
	else printf("电脑");
	printf("恢复了1点体力!\n");
	if (((*w1).tili) > ((*w1).tilishangxian))printf("你被撑死了!\n");
}
void Chai(wujiang*w1, wujiang*w2, pai qipaidui[104], int*qipaishu) {
	int i, x, y;
	if ((*w1).juese) {
		for (;;) {
			if ((*w2).shoupaishu + (*w2).zhuangbeishu + (*w2).pandingshu == 0) {
				printf("对方空城,拆你妹啊!\n");
				break;
			} else {
				printf("请选择想拆的区域,输入选项之前的编号,以回车结束!\n0 手牌\n1 装备区\n2 判定区\n");
				scanf("%d", &x);
				if (x == 0 && ((*w2).shoupaishu == 0))printf("你拆掉了一张空气!\n");
				else if (x == 1 && ((*w2).zhuangbeishu == 0))printf("你拆掉了一张空气!\n");
				else if (x == 2 && ((*w2).pandingshu == 0))printf("你拆掉了一张空气!\n");
				else if (x >= 0 && x <= 2)break;
				else printf("你拆掉了太空区里的一张牌!\n");
			}
		}
		switch (x) {
			case 0:
				srand((unsigned)time(NULL));
				y = rand() % ((*w2).shoupaishu);
				printf("你弃掉了电脑的");
				((*w2).shoupai)[y].Kanpai();
				qipaidui[*qipaishu] = ((*w2).shoupai)[y];
				for (i = y + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
				((*w2).shoupaishu)--;
				(*qipaishu)++;
				break;
			case 1:
				for (;;) {
					(*w2).Kanzhuangbei();
					printf("请输入装备之前的编号,以回车键结束!\n");
					scanf("%d", &y);
					if ((((*w2).zhuangbei[y]).leixing != -1) && (y >= 0) && (y <= 3)) {
						printf("你弃掉了电脑的");
						((*w2).zhuangbei)[y].Kanpai();
						qipaidui[*qipaishu] = ((*w2).zhuangbei)[y];
						((*w2).zhuangbeishu)--;
						(*qipaishu)++;
						((*w2).zhuangbei)[y].leixing = -1;
						if (!y)((*w2).zhuangbei)[y].changdu = 1;
						else if (y == 2)((*w2).juli[0])++;
						else if (y == 3)((*w1).juli[0])--;
						break;
					} else printf("你弃掉了一张空气!\n");
				}
				break;
			case 2:
				for (;;) {
					(*w2).Kanpandingpai();
					printf("请输入判定牌之前的编号,以回车键结束!\n");
					scanf("%d", &y);
					if ((*w2).pandingpai[y].leixing != -1) {
						printf("你弃掉了电脑的");
						((*w2).pandingpai)[y].Kanpai();
						qipaidui[*qipaishu] = ((*w2).pandingpai)[y];
						((*w2).pandingshu)--;
						(*qipaishu)++;
						((*w2).pandingpai)[y].leixing = -1;
						break;
					} else printf("你弃掉了一张空气!\n");
				}
				break;
			default:
				break;
		}
	} else {
		if ((*w2).zhuangbeishu) {
			if ((*w2).zhuangbei[1].leixing != -1) {
				printf("电脑弃掉了玩家的");
				((*w2).zhuangbei)[1].Kanpai();
				qipaidui[*qipaishu] = ((*w2).zhuangbei)[1];
				((*w2).zhuangbeishu)--;
				(*qipaishu)++;
				((*w2).zhuangbei)[1].leixing = -1;
			} else if ((*w2).zhuangbei[3].leixing != -1) {
				printf("电脑弃掉了玩家的");
				((*w2).zhuangbei)[3].Kanpai();
				qipaidui[*qipaishu] = ((*w2).zhuangbei)[3];
				((*w2).zhuangbeishu)--;
				(*qipaishu)++;
				((*w2).zhuangbei)[3].leixing = -1;
				((*w1).juli[0])--;
			} else if ((*w2).zhuangbei[0].leixing != -1) {
				printf("电脑弃掉了玩家的");
				((*w2).zhuangbei)[0].Kanpai();
				qipaidui[*qipaishu] = ((*w2).zhuangbei)[0];
				((*w2).zhuangbeishu)--;
				(*qipaishu)++;
				((*w2).zhuangbei)[0].leixing = -1;
				((*w2).zhuangbei)[0].changdu = 1;
			} else {
				printf("电脑弃掉了玩家的");
				((*w2).zhuangbei)[2].Kanpai();
				qipaidui[*qipaishu] = ((*w2).zhuangbei)[2];
				((*w2).zhuangbeishu)--;
				(*qipaishu)++;
				((*w2).zhuangbei)[2].leixing = -1;
				((*w2).juli[0])++;
			}
		} else {
			srand((unsigned)time(NULL));
			y = rand() % ((*w2).shoupaishu);
			printf("电脑弃掉了玩家的手牌");
			((*w2).shoupai)[y].Kanpai();
			qipaidui[*qipaishu] = ((*w2).shoupai)[y];
			for (i = y + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
			((*w2).shoupaishu)--;
			(*qipaishu)++;
		}
	}
}
void Qian(wujiang *w1, wujiang *w2) {
	int i, x, y;
	if ((*w1).juese) {
		for (;;) {
			if ((*w2).shoupaishu + (*w2).zhuangbeishu + (*w2).pandingshu == 0) {
				printf("对方空城啦!你牵走了一张寂寞!\n");
				break;
			} else {
				printf("请选择想牵的区域,输入选项之前的编号,以回车结束!\n0 手牌\n1 装备区\n2 判定区\n");
				scanf("%d", &x);
				if (x == 0 && ((*w2).shoupaishu == 0))printf("你牵走了一张空气!\n");
				else if (x == 1 && ((*w2).zhuangbeishu == 0))printf("你牵走了一张空气!\n");
				else if (x == 2 && ((*w2).pandingshu == 0))printf("你牵走了一张空气!\n");
				else if (x >= 0 && x <= 2)break;
				else printf("你牵走了太空区里的一张牌!\n");
			}
		}
		switch (x) {
			case 0:
				srand((unsigned)time(NULL));
				y = rand() % ((*w2).shoupaishu);
				printf("你牵走了电脑的");
				((*w2).shoupai)[y].Kanpai();
				(*w1).shoupai[(*w1).shoupaishu] = ((*w2).shoupai)[y];
				for (i = y + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
				((*w2).shoupaishu)--;
				((*w1).shoupaishu)++;
				break;
			case 1:
				for (;;) {
					(*w2).Kanzhuangbei();
					printf("请输入装备之前的编号,以回车键结束!\n");
					scanf("%d", &y);
					if ((((*w2).zhuangbei[y]).leixing != -1) && (y >= 0) && (y <= 3)) {
						printf("你牵走了电脑的");
						((*w2).zhuangbei)[y].Kanpai();
						(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[y];
						((*w2).zhuangbeishu)--;
						((*w1).shoupaishu)++;
						((*w2).zhuangbei)[y].leixing = -1;
						if (!y)((*w2).zhuangbei[y]).changdu = 1;
						else if (y == 2)((*w2).juli[0])++;
						else if (y == 3)((*w1).juli[0])--;
						break;
					} else printf("你弃掉了一张空气!\n");
				}
				break;
			case 2:
				for (;;) {
					(*w2).Kanpandingpai();
					printf("请输入判定牌之前的编号,以回车键结束!\n");
					scanf("%d", &y);
					if ((*w2).pandingpai[y].leixing != -1) {
						printf("你牵走了电脑的");
						((*w2).pandingpai)[y].Kanpai();
						(*w1).shoupai[(*w1).shoupaishu] = ((*w2).pandingpai)[y];
						((*w2).pandingshu)--;
						((*w1).shoupaishu)++;
						((*w2).pandingpai)[y].leixing = -1;
						break;
					} else printf("你牵走了一张空气!\n");
				}
				break;
			default:
				break;
		}
	} else {
		if ((*w2).zhuangbeishu) {
			if ((*w2).zhuangbei[1].leixing != -1) {
				printf("电脑牵走了玩家的");
				((*w2).zhuangbei)[1].Kanpai();
				(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[1];
				((*w2).zhuangbeishu)--;
				((*w1).shoupaishu)++;
				((*w2).zhuangbei)[1].leixing = -1;
			} else if ((*w2).zhuangbei[3].leixing != -1) {
				printf("电脑牵走了玩家的");
				((*w2).zhuangbei)[3].Kanpai();
				(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[3];
				((*w2).zhuangbeishu)--;
				((*w1).shoupaishu)++;
				((*w2).zhuangbei)[3].leixing = -1;
				((*w1).juli[0])--;
			} else if ((*w2).zhuangbei[0].leixing != -1) {
				printf("电脑牵走了玩家的");
				((*w2).zhuangbei)[0].Kanpai();
				(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[0];
				((*w2).zhuangbeishu)--;
				((*w1).shoupaishu)++;
				((*w2).zhuangbei)[0].leixing = -1;
				((*w2).zhuangbei)[0].changdu = 1;
			} else {
				printf("电脑牵走了玩家的");
				((*w2).zhuangbei)[2].Kanpai();
				(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[2];
				((*w2).zhuangbeishu)--;
				((*w1).shoupaishu)++;
				((*w2).zhuangbei)[2].leixing = -1;
				((*w2).juli[0])--;
			}
		} else {
			srand((unsigned)time(NULL));
			y = rand() % ((*w2).shoupaishu);
			printf("电脑牵走了玩家的手牌");
			((*w2).shoupai)[y].Kanpai();
			(*w1).shoupai[(*w1).shoupaishu] = ((*w2).shoupai)[y];
			for (i = y + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
			((*w2).shoupaishu)--;
			((*w1).shoupaishu)++;
		}
	}
}
void Wuzhong(wujiang*w1, pai A[104], int *x, pai B[104], int*y) {
	Mopai(&((*w1).shoupaishu), (*w1).shoupai, A, x, B, y, (*w1).juese);
}
int Juedou(wujiang*w1, wujiang*w2, pai qipaidui[104], int*qipaishu) {
	int i, j, x;
	if ((*w1).juese) {
		for (;;) {
			j = 0;
			for (x = 0; x < ((*w2).shoupaishu); x++) {
				if ((*w2).shoupai[x].leixing == 101) {
					printf("电脑打出");
					((*w2).shoupai)[x].Kanpai();
					qipaidui[*qipaishu] = ((*w2).shoupai)[x];
					for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
					((*w2).shoupaishu)--;
					(*qipaishu)++;
					j = 1;
					break;
				}
			}
			if (!j) {
				printf("玩家对电脑造成1点伤害!\n");
				((*w2).tili)--;
				i = Binsi(w1, w2, qipaidui, qipaishu);
				return i;
				break;
			}
			j = 0;
			for (;;) {
				printf("请打出一张【杀】响应【决斗】,否则你将受到1点伤害!\n请输入手牌之前的编号,或者输入“-1”放弃出【杀】,以回车结束!\n");
				if (((*w1).zhuangbei[0].leixing == 305))printf("如果想发动【丈八蛇矛】效果,请输入“100”,以回车结束!\n");
				(*w1).Kanshoupai();
				scanf("%d", &x);
				if (x == -1) {
					int i;
					((*w1).tili)--;
					printf("电脑对玩家造成1点伤害!\n");
					i = Binsi(w2, w1, qipaidui, qipaishu);
					return i;
					break;
				} else if (((*w1).zhuangbei[0].leixing == 305) && x == 100) {
					pai p = Zhangba(w1, qipaidui, qipaishu);
					p.paifu = -1;
					printf("打出!\n");
					j = 1;
					break;
				} else if ((*w1).shoupai[x].leixing == 101) {
					printf("玩家打出");
					((*w1).shoupai)[x].Kanpai();
					qipaidui[*qipaishu] = ((*w1).shoupai)[x];
					for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
					((*w1).shoupaishu)--;
					(*qipaishu)++;
					j = 1;
					break;
				} else printf("你确定你打出的是【杀】?\n");
			}
		}
	} else {
		for (;;) {
			j = 0;
			for (;;) {
				printf("请打出一张【杀】响应【决斗】,否则你将受到1点伤害!\n请输入手牌之前的编号,或者输入“-1”放弃出【杀】,以回车结束!\n");
				if (((*w1).zhuangbei[0].leixing == 305))printf("如果想发动【丈八蛇矛】效果,请输入“100”,以回车结束!\n");
				(*w2).Kanshoupai();
				scanf("%d", &x);
				if (x == -1) {
					int i;
					((*w2).tili)--;
					printf("电脑对玩家造成1点伤害!\n");
					i = Binsi(w1, w2, qipaidui, qipaishu);
					return i;
					break;
				} else if (((*w2).zhuangbei[0].leixing == 305) && x == 100) {
					pai p = Zhangba(w2, qipaidui, qipaishu);
					p.paifu = -1;
					printf("打出!\n");
					j = 1;
					break;
				} else if ((*w2).shoupai[x].leixing == 101) {
					printf("玩家打出");
					((*w2).shoupai)[x].Kanpai();
					qipaidui[*qipaishu] = ((*w2).shoupai)[x];
					for (i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
					((*w2).shoupaishu)--;
					(*qipaishu)++;
					j = 1;
					break;
				} else printf("你确定你打出的是【杀】?\n");
			}
			j = 0;
			for (x = 0; x < ((*w1).shoupaishu); x++) {
				if ((*w1).shoupai[x].leixing == 101) {
					printf("电脑打出");
					((*w1).shoupai)[x].Kanpai();
					qipaidui[*qipaishu] = ((*w1).shoupai)[x];
					for (int i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
					((*w1).shoupaishu)--;
					(*qipaishu)++;
					j = 1;
					break;
				}
			}
			if (!j) {
				printf("玩家对电脑造成1点伤害!\n");
				((*w2).tili)--;
				i = Binsi(w2, w1, qipaidui, qipaishu);
				return i;
				break;
			}
		}
	}
}
int Jiedao(wujiang*w1, wujiang*w2, pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
	int i, j = 0, x;
	if ((*w1).juese) {
		for (x = 0; x < ((*w2).shoupaishu); x++) {
			if ((*w2).shoupai[x].leixing == 101) {
				printf("电脑对玩家使用");
				((*w2).shoupai)[x].Kanpai();
				qipaidui[*qipaishu] = ((*w2).shoupai)[x];
				for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
				((*w2).shoupaishu)--;
				(*qipaishu)++;
				j = 1;
				break;
			}
		}
		if (j) {
			i = Sha(w2, w1, paidui, paiduishu, qipaidui, qipaishu);
			return i;
			printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
		} else {
			printf("电脑放弃使用【杀】,玩家获得电脑的武器");
			(*w2).zhuangbei[0].Kanpai();
			(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[0];
			((*w2).zhuangbeishu)--;
			((*w1).shoupaishu)++;
			((*w2).zhuangbei)[0].leixing = -1;
			((*w2).zhuangbei)[0].changdu = 1;
			(*w1).Kanshoupai();
			return 0;
		}
	} else {
		for (;;) {
			printf("请对电脑使用一张【杀】,否则电脑将获得你的武器!\n请输入手牌之前的编号,或者输入“-1”放弃出【杀】,以回车结束!\n");
			if (((*w2).zhuangbei[0].leixing == 305))printf("如果想发动【丈八蛇矛】效果,请输入“100”,以回车结束!\n");
			(*w2).Kanshoupai();
			scanf("%d", &x);
			if (x == -1)break;
			else if (((*w2).zhuangbei[0].leixing == 305) && x == 100) {
				pai p = Zhangba(w2, qipaidui, qipaishu);
				p.paifu = -1;
				printf("使用!\n");
				j = 1;
				break;
			} else if ((*w2).shoupai[x].leixing == 101) {
				printf("玩家对电脑使用");
				((*w2).shoupai)[x].Kanpai();
				qipaidui[*qipaishu] = ((*w2).shoupai)[x];
				for (i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
				((*w2).shoupaishu)--;
				(*qipaishu)++;
				j = 1;
				break;
			} else printf("你确定你使用的是【杀】?\n");
		}
		if (j) {
			i = Sha(w2, w1, paidui, paiduishu, qipaidui, qipaishu);
			return i;
			printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
		} else {
			printf("玩家放弃使用【杀】,电脑获得玩家的武器");
			((*w2).zhuangbei)[0].Kanpai();
			(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[0];
			((*w2).zhuangbeishu)--;
			((*w1).shoupaishu)++;
			((*w2).zhuangbei)[0].leixing = -1;
			((*w2).zhuangbei)[0].changdu = 1;
			return 0;
		}
	}
}
void Taoyuan(wujiang*w) {
	if ((*w).tili < (*w).tilishangxian) {
		((*w).tili)++;
		if ((*w).juese)printf("玩家");
		else printf("电脑");
		printf("恢复1点体力!\n");
	}
}
void Kaipai(pai paidui[104], int* paiduishu, int renshu, pai wugu[10]) {
	int i;
	printf("五谷丰登开牌:\n");
	for (i = 1; i <= renshu; i++) {
		wugu[i - 1] = paidui[104 - (*paiduishu)];
		(*paiduishu)--;
		printf("%d ", i - 1);
		wugu[i - 1].Kanpai();
	}
}
void Qupai(pai wugu[10], wujiang*w) {
	int i, x;
	printf("五谷丰登开牌:\n");
	for (i = 0; (wugu[i].leixing) != -1; i++) {
		printf("%d ", i);
		wugu[i].Kanpai();
	}
	if ((*w).juese) {
		for (;;) {
			printf("请选择你想要的卡牌,输入卡牌之前的编号,以回车结束!\n");
			scanf("%d", &x);
			if (wugu[x].leixing != -1) {
				printf("玩家选择");
				wugu[x].Kanpai();
				(*w).shoupai[(*w).shoupaishu] = wugu[x];
				((*w).shoupaishu)++;
				for (i = x + 1; i <= 9; i++)wugu[i - 1] = wugu[i];
				wugu[9].leixing = -1;
				break;
			}
			printf("你选择了一张空气加入手牌!");
		}
	} else {
		printf("电脑选择");
		wugu[0].Kanpai();
		(*w).shoupai[(*w).shoupaishu] = wugu[0];
		((*w).shoupaishu)++;
		for (i = 1; i <= 9; i++)wugu[i - 1] = wugu[i];
		wugu[9].leixing = -1;
	}
}
void Rengpai(pai wugu[10], pai qipaidui[104], int*qipaishu) {
	int i;
	for (i = 0; wugu[i].leixing != -1; i++) {
		qipaidui[*qipaishu] = wugu[i];
		(*qipaishu)++;
		wugu[i].leixing = -1;
	}
}
int Nanman(wujiang*w1, wujiang*w2, pai qipaidui[104], int*qipaishu) {
	int i, x;
	if ((*w1).juese) {
		for (x = 0; x < ((*w2).shoupaishu); x++) {
			if ((*w2).shoupai[x].leixing == 101) {
				printf("电脑打出");
				((*w2).shoupai)[x].Kanpai();
				qipaidui[*qipaishu] = ((*w2).shoupai)[x];
				for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
				((*w2).shoupaishu)--;
				(*qipaishu)++;
				return 0;
				break;
			}
		}
		printf("玩家对电脑造成1点伤害!\n");
		((*w2).tili)--;
		i = Binsi(w1, w2, qipaidui, qipaishu);
		return i;
	} else {
		for (;;) {
			printf("请打出一张【杀】响应【南蛮入侵】,否则你将受到1点伤害!\n请输入手牌之前的编号,或者输入“-1”放弃出【杀】,以回车结束!\n");
			if (((*w2).zhuangbei[0].leixing == 305))printf("如果想发动【丈八蛇矛】效果,请输入“100”,以回车结束!\n");
			(*w2).Kanshoupai();
			scanf("%d", &x);
			if (x == -1) {
				int i;
				((*w2).tili)--;
				printf("电脑对玩家造成1点伤害!\n");
				i = Binsi(w1, w2, qipaidui, qipaishu);
				return i;
				break;
			} else if (((*w2).zhuangbei[0].leixing == 305) && x == 100) {
				pai p = Zhangba(w2, qipaidui, qipaishu);
				p.paifu = -1;
				printf("使用!\n");
				return 0;
				break;
			} else if ((*w2).shoupai[x].leixing == 101) {
				printf("玩家打出");
				((*w2).shoupai)[x].Kanpai();
				qipaidui[*qipaishu] = ((*w2).shoupai)[x];
				for (i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
				((*w2).shoupaishu)--;
				(*qipaishu)++;
				return 0;
				break;
			} else printf("你确定你打出的是【杀】?\n");
		}
	}
}
int Wanjian(wujiang*w1, wujiang*w2, pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
	int i;
	i = Shan(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
	if (i == -1) {
		i = Binsi(w1, w2, qipaidui, qipaishu);
		return i;
	} else return 0;
}
int Chupai(pai paidui[104], pai qipaidui[104], int *paiduishu, int*qipaishu, wujiang*w1, wujiang*w2, pai yuanshipaidui[2][4][13]) {
	pai p1;
	int sha = 1;
	int y = -1, i, t = ((*w1).shoupaishu) - 1;
	for (;; t--) {
 
		if ((*w1).juese) {
			printf("\n电脑当前手牌数:%d\n", ((*w2).shoupaishu));
			(*w2).Kanzhuangbei();
			(*w1).Kanshoupai();
			(*w1).Kanzhuangbei();
		}
		int j = 0;
		if ((*w1).juese && ((*w1).zhuangbei[0].leixing == 305))printf("如果想发动【丈八蛇矛】效果,请输入“100”,以回车结束!\n");
		y = Xuanpai(w1, t);
		p1 = Panpai(w1, &sha, y, qipaidui, qipaishu);
		if ((p1).leixing == -1)break;
		else if ((p1).leixing == 0)continue;
		else {
			int duixiang;
			duixiang = Mubiao(p1, w1, w2, &sha);
			if (duixiang == -2)continue;
			else {
				Da1pai(w1, w2, qipaidui, qipaishu, y);
				Miaoshu(p1, ((*w1).juese), duixiang);
				if (!((*w1).juese)) {
					printf("\n电脑当前手牌数:%d\n", ((*w1).shoupaishu));
					(*w1).Kanzhuangbei();
					(*w2).Kanshoupai();
					(*w2).Kanzhuangbei();
				}
				switch (p1.leixing) {
					case 101:
						i = Sha(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
						if (i == -1) {
							return -1;
							break;
						}
						if ((*w1).juese)printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
						else printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
						break;
					case 103:
						Tao(w1);
						break;
					case 201:
						for (;;) {
							i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
						}
						if (!(j % 2))Chai(w1, w2, qipaidui, qipaishu);
						else;
						if ((*w1).juese)(*w1).Kanshoupai();
						break;
					case 202:
						for (;;) {
							i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
						}
						if (!(j % 2))Qian(w1, w2);
						else;
						if ((*w1).juese)(*w1).Kanshoupai();
						break;
					case 203:
						for (;;) {
							i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
						}
						if (!(j % 2))Wuzhong(w1, paidui, paiduishu, qipaidui, qipaishu);
						else;
						break;
					case 204:
						for (;;) {
							i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
						}
						if (!(j % 2)) {
							i = Juedou(w1, w2, qipaidui, qipaishu);
							if (i == -1)return -1;
							if ((*w1).juese)printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
							else printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
						}
						break;
					case 205:
						for (;;) {
							i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
						}
						if (!(j % 2)) {
							i = Jiedao(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
							if (i == -1)return -1;
							if ((*w1).juese)printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
							else printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
						}
						break;
					case 206:
						for (;;) {
							i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
						}
						if (!(j % 2))Taoyuan(w1);
						j = 0;
						for (;;) {
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
						}
						if (!(j % 2))Taoyuan(w2);
						break;
					case 207:
						pai wugu[10];
						for (i = 1; i <= 10; i++)wugu[i - 1].leixing = -1;
						Kaipai(paidui, paiduishu, 2, wugu);
						for (;;) {
							i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
						}
						if (!(j % 2))Qupai(wugu, w1);
						for (;;) {
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
						}
						if (!(j % 2))Qupai(wugu, w2);
						Rengpai(wugu, qipaidui, qipaishu);
						printf("弃牌数:%d\n", *qipaishu);
						break;
					case 208:
						for (;;) {
							i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
						}
						if (!(j % 2)) {
							i = Nanman(w1, w2, qipaidui, qipaishu);
							if (i == -1)return -1;
							if ((*w1).juese)printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
							else printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
						}
						break;
					case 209:
						for (;;) {
							i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
							i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
							if (!i)break;
							j++;
						}
						if (!(j % 2)) {
							i = Wanjian(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
							if (i == -1)return -1;
							if ((*w1).juese)printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
							else printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
						}
						break;
					case 361:
					case 362:
					case 363:
						((*w1).juli[0])--;
						break;
					case 381:
					case 382:
					case 383:
						((*w2).juli[0])++;
						break;
					default:
						break;
				}
				printf("\n");
			}
		}
	}
	return 0;
}
void Qipai(pai shoupai[20], int *shoupaishu, pai qipaidui[104], int *qipaishu, int juese, int *shoupaishangxian) {
	int x;
	if ((*shoupaishu) > (*shoupaishangxian)) {
		if (juese != 1 && juese != 0)printf("身份参数错误!");
		int q = (*shoupaishu) - (*shoupaishangxian);
		int i, j;
		for (j = 1; j <= q; j++) {
			for (;;) {
				if (juese) {
					printf("弃牌请输入手牌之前的编号,以回车结束!\n注:一次只能弃一张牌\n");
					printf("手牌数:%d\n", *shoupaishu);
					scanf("%d", &x);
					if (x >= 0 && x < (*shoupaishu))break;
					else printf("你弃掉了一张空气!\n");
				} else {
					srand((unsigned)time(NULL));
					x = rand() % (*shoupaishu);
					break;
				}
			}
			qipaidui[*qipaishu] = shoupai[x];
			for (i = x + 1; i <= (*shoupaishu); i++)shoupai[i - 1] = shoupai[i];
			(*shoupaishu)--;
			if (juese)printf("弃牌阶段玩家弃置");
			else printf("弃牌阶段电脑弃置");
			qipaidui[*qipaishu].Kanpai();
			(*qipaishu)++;
			int m;
			if (juese) {
				printf("玩家当前手牌:\n");
				for (m = 0; m <= (*shoupaishu - 1); m++) {
					printf("%d ", m);
					(shoupai[m]).Kanpai();
				}
			}
			printf("弃牌堆:%d\n", *qipaishu);
		}
	}
}
int Huihe(pai A[104], pai B[104], int *x, int *y, pai yuanshipaidui[2][4][13], wujiang *w1, wujiang *w2) {
	printf("\n回合开始阶段……\n");
	switch ((*w1).huihekaishi) {
		case 0:
			break;
		default:
			printf("回合开始阶段参数错误!\n");
			break;
	}
	printf("判定阶段……\n");
	int K = 0;
	if ((*w1).pandingshu > 0) {
		int i, j;
		for (; (*w1).pandingshu;) {
			switch ((*w1).pandingpai[0].leixing) {
				case 251:
					printf("【乐不思蜀】开始判定……\n");
					break;
				case 252:
					printf("【闪电】开始判定……\n");
					break;
				default:
					printf("【??】开始判定……\n");
					break;
			}
			j = 0;
			pai p = ((*w1).pandingpai[0]);
			for (;;) { //在判定之前询问【无懈】
				i = Wuxie(&p, w2, w1, B, y, 0);
				if (!i)break;
				j++;
				i = Wuxie(&p, w1, w2, B, y, 0);
				if (!i)break;
				j++;
			}
			switch ((*w1).pandingpai[0].leixing) {
				case 251:
					if (!(j % 2)) {
						printf("【乐不思蜀】的判定牌是:");
						Panding(A, x, B, y);
						if ((B[(*y) - 1].huase) != 1) {
							printf("【乐不思蜀】判定成功!\n");
							if ((*w1).juese)printf("玩家");
							else printf("电脑");
							printf("跳过出牌阶段!\n");
							K = -1;
						} else printf("【乐不思蜀】判定失败!\n");
					}
					B[*y] = (*w1).pandingpai[0];
					((*w1).pandingshu)--;
					(*w1).pandingpai[0] = (*w1).pandingpai[1];
					(*w1).pandingpai[1] = (*w1).pandingpai[2];
					(*w1).pandingpai[2].leixing = -1;
					(*y)++;
					break;
				case 252:
					if (!(j % 2)) {
						printf("【闪电】的判定牌是:");
						Panding(A, x, B, y);
						if ((B[(*y) - 1].huase == 0) && (B[(*y) - 1].dianshu >= 1) && (B[(*y) - 1].dianshu <= 8)) {
							printf("【闪电】判定成功!\n");
							if ((*w1).juese)printf("玩家");
							else printf("电脑");
							printf("受到3点雷电伤害!");
							((*w1).tili) = ((*w1).tili) - 3;
							i = Binsi(w2, w1, B, y);
							B[*y] = (*w1).pandingpai[0];
							((*w1).pandingshu)--;
							(*w1).pandingpai[0] = (*w1).pandingpai[1];
							(*w1).pandingpai[1] = (*w1).pandingpai[2];
							(*w1).pandingpai[2].leixing = -1;
							(*y)++;
							if (i == -1)return -1;
						} else {
							printf("【闪电】判定失败!\n");
							(*w2).pandingpai[2] = (*w2).pandingpai[1];
							(*w2).pandingpai[1] = (*w2).pandingpai[0];
							(*w2).pandingpai[0] = (*w1).pandingpai[0];
							(*w1).pandingpai[0] = (*w1).pandingpai[1];
							(*w1).pandingpai[1] = (*w1).pandingpai[2];
							(*w1).pandingpai[2].leixing = -1;
							((*w1).pandingshu)--;
							((*w2).pandingshu)++;
						}
						break;
					}
				default:
					printf("判定牌错误!");
			}
			printf("弃牌数:%d\n", *y);
		}
	} else if (!((*w1).pandingshu));
	else printf("判定阶段参数错误!\n");
	printf("摸牌阶段……\n");
	switch ((*w1).mopai) {
		case 0:
			Mopai(&((*w1).shoupaishu), (*w1).shoupai, A, x, B, y, (*w1).juese);
			break;
		case -1:
			break;
		default:
			printf("摸牌阶段参数错误!\n");
			break;
	}
	if (K == -1)goto M;
	printf("出牌阶段……\n");
	switch ((*w1).chupai) {
		case 0: {
			int i;
			i = Chupai(A, B, x, y, w1, w2, yuanshipaidui);
			if (i == -1) {
				return -1;
				break;
			} else break;
		}
		case -1:
			break;
		default:
			printf("出牌阶段参数错误!\n");
			break;
	}
M:
	printf("弃牌阶段……\n");
	switch ((*w1).qipai) {
		case 0:
			Qipai((*w1).shoupai, &((*w1).shoupaishu), B, y, (*w1).juese, &((*w1).tili));
			break;
		default:
			printf("弃牌阶段参数错误!\n");
			break;
	}
	printf("回合结束阶段……\n");
	switch ((*w1).huihejieshu) {
		case 0:
			break;
		default:
			printf("回合结束阶段参数错误!\n");
			break;
	}
	return 0;
}
int main() {
	void Kanshoupai(pai p);
	pai yuanshipaidui[2][4][13], qipaidui[104], paidui[104];
	wujiang wanjia, com;
	com.tili = wanjia.tili = 5;
	com.tilishangxian = wanjia.tilishangxian = 5;
	com.huihekaishi = wanjia.huihekaishi = 0;
	com.panding = wanjia.panding = 0;
	com.mopai = wanjia.mopai = 0;
	com.chupai = wanjia.chupai = 0;
	com.qipai = wanjia.qipai = 0;
	com.huihejieshu = wanjia.huihejieshu = 0;
	com.shoupaishu = wanjia.shoupaishu = 0;
	com.pandingshu = wanjia.pandingshu = 0;
	com.zhuangbeishu = wanjia.zhuangbeishu = 0;
	com.juese = 0;
	wanjia.juese = 1;
	pai p;
	p.leixing = -1;
	com.zhuangbei[0] = com.zhuangbei[1] = com.zhuangbei[2] = com.zhuangbei[3] = wanjia.zhuangbei[0] = wanjia.zhuangbei[1] = wanjia.zhuangbei[2] = wanjia.zhuangbei[3] = p;
	com.zhuangbei[0].changdu = wanjia.zhuangbei[0].changdu = 1;
	com.pandingpai[0] = com.pandingpai[1] = com.pandingpai[2] = wanjia.pandingpai[0] = wanjia.pandingpai[1] = wanjia.pandingpai[2] = p;
	com.juli[0] = wanjia.juli[0] = 1;
	int a, b, c;
	for (a = 0; a <= 1; a++) {
		for (b = 0; b <= 3; b++) {
			for (c = 0; c <= 12; c++) {
				yuanshipaidui[a][b][c].paifu = a;
				yuanshipaidui[a][b][c].huase = b;
				yuanshipaidui[a][b][c].dianshu = c;
			}
		}
	}
	yuanshipaidui[0][0][0].leixing = 204;
	yuanshipaidui[0][0][1].leixing = 331;
	yuanshipaidui[0][0][2].leixing = 201;
	yuanshipaidui[0][0][3].leixing = 201;
	yuanshipaidui[0][0][4].leixing = 304;
	yuanshipaidui[0][0][4].changdu = 3;
	yuanshipaidui[0][0][5].leixing = 251;
	yuanshipaidui[0][0][6].leixing = 101;
	yuanshipaidui[0][0][7].leixing = 101;
	yuanshipaidui[0][0][8].leixing = 101;
	yuanshipaidui[0][0][9].leixing = 101;
	yuanshipaidui[0][0][10].leixing = 202;
	yuanshipaidui[0][0][11].leixing = 201;
	yuanshipaidui[0][0][12].leixing = 208;
	yuanshipaidui[0][1][0].leixing = 209;
	yuanshipaidui[0][1][1].leixing = 102;
	yuanshipaidui[0][1][2].leixing = 103;
	yuanshipaidui[0][1][3].leixing = 103;
	yuanshipaidui[0][1][4].leixing = 308;
	yuanshipaidui[0][1][4].changdu = 5;
	yuanshipaidui[0][1][5].leixing = 103;
	yuanshipaidui[0][1][6].leixing = 103;
	yuanshipaidui[0][1][7].leixing = 103;
	yuanshipaidui[0][1][8].leixing = 103;
	yuanshipaidui[0][1][9].leixing = 101;
	yuanshipaidui[0][1][10].leixing = 101;
	yuanshipaidui[0][1][11].leixing = 103;
	yuanshipaidui[0][1][12].leixing = 102;
	yuanshipaidui[0][2][0].leixing = 204;
	yuanshipaidui[0][2][1].leixing = 101;
	yuanshipaidui[0][2][2].leixing = 101;
	yuanshipaidui[0][2][3].leixing = 101;
	yuanshipaidui[0][2][4].leixing = 101;
	yuanshipaidui[0][2][5].leixing = 101;
	yuanshipaidui[0][2][6].leixing = 101;
	yuanshipaidui[0][2][7].leixing = 101;
	yuanshipaidui[0][2][8].leixing = 101;
	yuanshipaidui[0][2][9].leixing = 101;
	yuanshipaidui[0][2][10].leixing = 101;
	yuanshipaidui[0][2][11].leixing = 205;
	yuanshipaidui[0][2][12].leixing = 205;
	yuanshipaidui[0][3][0].leixing = 204;
	yuanshipaidui[0][3][1].leixing = 102;
	yuanshipaidui[0][3][2].leixing = 102;
	yuanshipaidui[0][3][3].leixing = 102;
	yuanshipaidui[0][3][4].leixing = 102;
	yuanshipaidui[0][3][5].leixing = 101;
	yuanshipaidui[0][3][6].leixing = 101;
	yuanshipaidui[0][3][7].leixing = 101;
	yuanshipaidui[0][3][8].leixing = 101;
	yuanshipaidui[0][3][9].leixing = 101;
	yuanshipaidui[0][3][10].leixing = 102;
	yuanshipaidui[0][3][11].leixing = 103;
	yuanshipaidui[0][3][12].leixing = 101;
	yuanshipaidui[1][0][0].leixing = 252;
	yuanshipaidui[1][0][1].leixing = 302;
	yuanshipaidui[1][0][1].changdu = 2;
	yuanshipaidui[1][0][2].leixing = 202;
	yuanshipaidui[1][0][3].leixing = 202;
	yuanshipaidui[1][0][4].leixing = 383;
	yuanshipaidui[1][0][5].leixing = 303;
	yuanshipaidui[1][0][5].changdu = 2;
	yuanshipaidui[1][0][6].leixing = 208;
	yuanshipaidui[1][0][7].leixing = 101;
	yuanshipaidui[1][0][8].leixing = 101;
	yuanshipaidui[1][0][9].leixing = 101;
	yuanshipaidui[1][0][10].leixing = 210;
	yuanshipaidui[1][0][11].leixing = 305;
	yuanshipaidui[1][0][11].changdu = 3;
	yuanshipaidui[1][0][12].leixing = 362;
	yuanshipaidui[1][1][0].leixing = 206;
	yuanshipaidui[1][1][1].leixing = 102;
	yuanshipaidui[1][1][2].leixing = 207;
	yuanshipaidui[1][1][3].leixing = 207;
	yuanshipaidui[1][1][4].leixing = 361;
	yuanshipaidui[1][1][5].leixing = 251;
	yuanshipaidui[1][1][6].leixing = 203;
	yuanshipaidui[1][1][7].leixing = 203;
	yuanshipaidui[1][1][8].leixing = 203;
	yuanshipaidui[1][1][9].leixing = 101;
	yuanshipaidui[1][1][10].leixing = 203;
	yuanshipaidui[1][1][11].leixing = 201;
	yuanshipaidui[1][1][12].leixing = 381;
	yuanshipaidui[1][2][0].leixing = 301;
	yuanshipaidui[1][2][0].changdu = 1;
	yuanshipaidui[1][2][1].leixing = 331;
	yuanshipaidui[1][2][2].leixing = 201;
	yuanshipaidui[1][2][3].leixing = 201;
	yuanshipaidui[1][2][4].leixing = 382;
	yuanshipaidui[1][2][5].leixing = 251;
	yuanshipaidui[1][2][6].leixing = 208;
	yuanshipaidui[1][2][7].leixing = 101;
	yuanshipaidui[1][2][8].leixing = 101;
	yuanshipaidui[1][2][9].leixing = 101;
	yuanshipaidui[1][2][10].leixing = 101;
	yuanshipaidui[1][2][11].leixing = 210;
	yuanshipaidui[1][2][12].leixing = 210;
	yuanshipaidui[1][3][0].leixing = 301;
	yuanshipaidui[1][3][0].changdu = 1;
	yuanshipaidui[1][3][1].leixing = 102;
	yuanshipaidui[1][3][2].leixing = 202;
	yuanshipaidui[1][3][3].leixing = 202;
	yuanshipaidui[1][3][4].leixing = 306;
	yuanshipaidui[1][3][4].changdu = 3;
	yuanshipaidui[1][3][5].leixing = 102;
	yuanshipaidui[1][3][6].leixing = 102;
	yuanshipaidui[1][3][7].leixing = 102;
	yuanshipaidui[1][3][8].leixing = 102;
	yuanshipaidui[1][3][9].leixing = 102;
	yuanshipaidui[1][3][10].leixing = 102;
	yuanshipaidui[1][3][11].leixing = 307;
	yuanshipaidui[1][3][11].changdu = 4;
	yuanshipaidui[1][3][12].leixing = 363;
	int paiduishu = 104;
	int qipaishu = 0;
	printf("游戏开始! by cyh\n");
	Qishixipai(yuanshipaidui, paidui);
	Qishishoupai(&wanjia, paidui, &(paiduishu), qipaidui, &(qipaishu));
	Qishishoupai(&com, paidui, &(paiduishu), qipaidui, &(qipaishu));
	int i;
	for (;;) {
		i = Huihe(paidui, qipaidui, &paiduishu, &qipaishu, yuanshipaidui, &wanjia, &com);
		if (i == -1)break;
		i = Huihe(paidui, qipaidui, &paiduishu, &qipaishu, yuanshipaidui, &com, &wanjia);
		if (i == -1)break;
	}
}

贪吃蛇

C++
#include <iostream>
#include <list>
#include <cstdio>
#include <string>
#include <vector>
#include <ctime>
#include <algorithm>
#include <conio.h>
#include <windows.h>
using namespace std;
class Node {
public:
    int x, y;
    Node(int x1, int y1);
};
 
class UserData {
public:
    string name;
    long long score;
    int gt;
    int gr;
    UserData(string s, long long sc,int gametime,int grade);
    friend bool operator < (UserData a, UserData b);
};
 
#define RIGHT 0x4d
#define LEFT 0x4b
#define UP 0x48
#define DOWN 0x50
#define YELLOW FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define CYAN FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define ORANGE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define PURPLE FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY
#define RED  FOREGROUND_RED | FOREGROUND_INTENSITY
const int STARTX = 8;
const int STARTY = 4;
const int RANGEX = 60;
const int RANGEY = 20;
int point=10;
const int ENDX = STARTX + RANGEX;
const int ENDY = STARTY + RANGEY;
bool isSnake[RANGEY + 10 ][RANGEX + 10];
int speed;
int sysj;
int gametime;
list<Node> snake;
int curDiraction; //蛇的当前前进方向, 1上, 2下, 3左, 4右
int score; //当前分数
int grade;
int snakeLen; //蛇的长度
int foodx, foody; //食物坐标
int gox, goy; //蛇头坐标
int mj;
void GoTo(short x, short y); //定位光标
void DrawBoard(); //绘制边框
void ShowInformation(); //展示游戏信息
void Init(); //初始化游戏
void RunSnake(int x, int y); //绘制蛇身
void Try(int& x, int& y); //试走
bool IsGoodCoord(int x, int y); //前进坐标是否合法
void AddFood();
void EartFood();
void InitSnake();
bool EndGame();
bool StartGame();
bool GameMenu(); //游戏菜单
void ShowRanking(); //排行榜
void ShowAbout(); //相关信息
void InputData(); //输入玩家名字
 
int main() {
    while (true) {
        if (!GameMenu()) return 0;
    }
    return 0;
}
 
Node::Node(int x1, int y1) { //构造Node对象
    x = x1; y = y1;
}
 
int SuiJi()
{
srand((unsigned)time(NULL));
return (rand()*rand()+rand()*rand())%14;
}
 
bool operator < (UserData a, UserData b) { //重载运算符,按分数由大到小排列
    if(a.score != b.score)
    return a.score > b.score;
    if(a.gt !=b.gt)
    return a.gt > b.gt;
    else
    return a.gr > b.gr;
}
UserData::UserData(string s, long long sc,int gametime_,int _grade) { //构造UserData对象
    name = s; score = sc; gt=gametime_; gr=_grade;
}
 
void color(WORD A)
{
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), A);
}
 
void Color(int a)
{
    switch (a%4)
    {
        case 0:color(RED);break;
        case 1:color(CYAN);break;
        case 2:color(YELLOW);break;
        case 3:color(PURPLE);break;
    }
}
 
void GoTo(short x, short y) { //定位光标
    COORD coord = { x, y };
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
 
void ShowInformation() { //输出游戏信息
    color(YELLOW);
    GoTo(78, 5);
    printf("贪吃蛇游戏");
    GoTo(78,18);
    gametime=(clock()-mj)/1000;
    grade=snakeLen-3;
    printf("生存时间:%3d 秒",(clock()-mj)/1000);
    GoTo(78, 8);
    printf("游戏规则:");
    GoTo(78, 10);
    printf("请按 ↑ ↓ ← →  来控制您的蛇吃东西");
    GoTo(78, 12);
    printf("吃的越多,蛇就越长,您的等级也将越高");
    GoTo(78, 14);
    printf("当蛇吃到自己或撞上墙时,游戏结束。");
    GoTo(78,16);
    printf("自动前进时间:%3dms",speed);
    GoTo(78, 20);
    printf("当前等级: %8d", snakeLen-3);
    GoTo(78, 23);
    printf("您的分数: %d", score);
    color(CYAN);
    printf("+%d=%d",score/3,score*3/2);
    color(YELLOW);
    GoTo(78,25);
    printf("剩余时间:%d秒",20+(snakeLen-3)*5-gametime);
    sysj=20+(snakeLen-3)*5-gametime;
}
 
void DrawBoard() { //绘制墙体
 
    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); //获得输出句柄
 
    CONSOLE_CURSOR_INFO cursor_info = { 1, 0 }; //光标信息
    SetConsoleCursorInfo(hOut, &cursor_info); //隐藏光标
 
    COORD size = { 120, 30 };
    SetConsoleScreenBufferSize(hOut, size); //重设缓冲区大小
 
    SMALL_RECT rc = { 0 , 0, 120, 30 };
    SetConsoleWindowInfo(hOut, true, &rc); //重设窗口大小
 
    SetConsoleTextAttribute(hOut, CYAN);
 
    for (int i = STARTX - 2; i <= ENDX + 2; i += 2) { //横向墙体
        GoTo(i, STARTY - 1);
        printf("■");
        GoTo(i, ENDY + 1);
        printf("■");
    }
    for (int i = STARTY - 1; i <= ENDY + 1; ++i) { //竖向墙体
        GoTo(STARTX - 2, i);
        printf("■");
        GoTo(ENDX + 2, i);
        printf("■");
    }
}
void draw()
{
    char m=snakeLen+62;
    Color(score);
    cout<<m;
 }
void Init() { //初始化游戏
    system("cls");
    memset(isSnake, 0, sizeof(isSnake));
    speed = 200;
    curDiraction = 4;
    score = 0;
    DrawBoard();
    InitSnake();
    ShowInformation();
    AddFood();
    mj=clock();
    point=20;
    sysj=20;
}
 
void RunSnake(int x, int y) { //绘制蛇身
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
    score += snakeLen + 1;
    if (x == foodx && y == foody) {
        EartFood();
        AddFood();
        return;
    }
    DrawBoard();
    snake.push_front(Node(x, y));
    isSnake[y][x] = true;
    GoTo(x, y);
    draw();
    Node back = snake.back();
    snake.pop_back();
    isSnake[back.y][back.x] = false;
    GoTo(back.x, back.y);
    printf(" ");
}
 
void Try(int& x, int& y) { //试走
    int key, cnt = 100;
    while (cnt--) { //多次检测键盘状态
        if (_kbhit()) {
            key = getch();
            switch (key) {
            case UP:
//                if (curDiraction == 1 || curDiraction == 2) break;
                --y; curDiraction = 1; return;
            case DOWN:
//                if (curDiraction == 1 || curDiraction == 2) break;
                ++y; curDiraction = 2; return;
            case LEFT:
//                if (curDiraction == 3 || curDiraction == 4) break;
                x -= 2; curDiraction = 3; return;
            case RIGHT:
//                if (curDiraction == 3 || curDiraction == 4) break;
                x += 2; curDiraction = 4; return;
            }
        }
    }
    if (curDiraction == 1) --y; //用户没有输入时
    else if (curDiraction == 2) ++y;
    else if (curDiraction == 3) x -= 2;
    else x += 2;
}
 
bool IsGoodCoord(int x, int y) { //判断光标是否合法
    if (x <= ENDX && y <= ENDY && x >= STARTX && y >= STARTY)
        return true;
    else
        return false;
}
 
void AddFood() { //增加食物
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), PURPLE);
    srand((unsigned)time(NULL));
    while (true) {
        foodx = (rand()%ENDX) + 1;
        foody = (rand()%ENDY) + 1;
        if (foodx&1) foodx++;
        if (!isSnake[foody][foodx] && IsGoodCoord(foodx, foody)) break;
    }
    GoTo(foodx, foody);
    int a=rand()%5;
    if(a>=4)
    printf("@");
    else if(a<=1)
    printf("#");
    else
    printf("&");
}
 
void EartFood() { //吃东西
    point+=4;
    int sb=gametime=(clock()-mj)/1000;
    sysj=point-sb;
    score+=score/2;
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
    snake.push_front(Node(foodx, foody));
    isSnake[foody][foodx] = true;
    ++snakeLen;
    if (speed >= 55) speed -= 5;
 
    GoTo(foodx, foody);
    draw();
    AddFood();
}
 
void InitSnake() { //初始化蛇身
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
    snakeLen = 3, gox = 18, goy = 14;
    snake.clear();
    snake.push_front(Node(12, 14));
    snake.push_front(Node(14, 14));
    snake.push_front(Node(16, 14));
    for (int i = 12; i <= 16; i += 2) {
        GoTo(i, 14);
        draw();
        isSnake[14][i] = true;
    }
}
bool EndGame() { //结束游戏
    system("cls");
    DrawBoard();
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
    GoTo(28, 10);
    printf("您的本局游戏得分: %d分", score);
    GoTo(32, 18);
    printf("....你挂了....");
    GoTo(27, 20);
    printf("是否继续游戏: 是(1), 否(0)");
    GoTo(27, 22);
    char key = getch();
    while (true) {
        if (key == '1') return false;
        else if (key == '0')
        {GoTo(ENDX+1,ENDY+2);
        exit(0);return true;
        }
        else key = getch();
    }
}
 
bool StartGame() { //启动游戏
 
    Init();
 
    while (sysj>0) { //开挂
        RunSnake(gox, goy);
        ShowInformation();
        Try(gox, goy);
        Sleep(speed);
    }
    InputData();
    return true;
}
 
bool GameMenu() { //游戏菜单
    system("cls");
    DrawBoard();
    GoTo(STARTX + 22, STARTY + 4);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
    printf("欢迎进入贪吃蛇游戏!");
    GoTo(STARTX + 24, STARTY + 10);
    printf("1: 新游戏");
    GoTo(STARTX + 24, STARTY + 12);
    printf("2: 排行榜");
    GoTo(STARTX + 24, STARTY + 14);
    printf("3: 关于游戏");
    GoTo(STARTX + 24, STARTY + 16);
    printf("4: 退出游戏");
 
    while (true) {
        if (_kbhit()) {
            char key = getch();
            switch (key) {
            case '1':
                if (!StartGame()) return false;
                else return true;
            case '2':
                ShowRanking(); return true;
            case '3':
                ShowAbout(); return true;
            case '4':
                GoTo(1,ENDY+2);
                return false;
            default:
                return true;
            }
        }
    }
}
 
void ShowRanking() { //展示排行榜
    vector<UserData> vu;
    FILE *fp = fopen("Gamedata2.txt", "r");
    if (fp == NULL) fp = fopen("Gamedata2.txt", "w+");
    char name[20];
    int len = 0;
    while (fscanf(fp, "%s", name) != EOF) {
        ++len;
        int score,g=grade;
        fscanf(fp, "%d%d%d%*c", &score,&gametime,&g);
        vu.push_back(UserData(string(name), score,gametime,g));
    }
    fclose(fp);
    sort(vu.begin(), vu.end()); //对得分进行排名
    system("cls");
    DrawBoard();
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), CYAN);
    GoTo(STARTX + 8, STARTY + 2);
    printf("用户");
    GoTo(STARTX + 20, STARTY + 2);
    printf("分数");
    GoTo(STARTX + 32, STARTY + 2);
    printf("生存时间");
    GoTo(STARTX + 44, STARTY + 2);
    printf("排行");
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
 
    for (int i = 0; i < len && i < 10; ++i) { //打印前十名用户数据
        char const *p = vu[i].name.c_str();
        Color(score);
        GoTo(STARTX + 8, STARTY + 4 + i);
        printf("%s", p);
        GoTo(STARTX + 20, STARTY + 4 + i);
        printf("%d分", vu[i].score);
        GoTo(STARTX + 32, STARTY + 4 + i);
        printf("%d秒", vu[i].gt);
        GoTo(STARTX + 44, STARTY + 4 + i);
        printf(" %d", i + 1);
    }
 
    GoTo(STARTX + 4, ENDY - 2);
    printf("-----------------  按'1'返回游戏菜单  ---------------");
    while (true) {
        if (_kbhit()) {
            char key = getch();
            if (key == '1') break;
        }
    }
}
 
void ShowAbout() { //展示游戏相关
    system("cls");
    DrawBoard();
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
 
    GoTo(STARTX + 4, STARTY + 2);
    printf("-------------------  贪吃蛇游戏  -------------------");
    GoTo(STARTX + 10,STARTY + 8);
    printf("贪吃蛇游戏");
    GoTo(STARTX + 10,STARTY + 10);
    printf("游戏规则:");
    GoTo(STARTX + 10,STARTY + 12);
    printf("请按 ↑ ↓ ← →  来控制您的蛇吃东西");
    GoTo(STARTX + 10,STARTY + 14);
    printf("吃的越多,蛇就越长,您的等级也将越高");
    GoTo(STARTX + 10,STARTY + 16);
    printf("当蛇吃到自己或撞上墙时,游戏结束。");
 
    GoTo(STARTX + 4, ENDY - 2);
    printf("-----------------  按'1'返回游戏菜单  ---------------");
    while (true) {
        if (_kbhit()) {
            char key = getch();
            if (key == '1') break;
        }
    }
}
 
void InputData() { //用户输入名字
    char name[20];
    if(score>=1000)
    {
    GoTo(STARTX + 10, STARTY + 10);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), RED);
    printf("请输入你的名字: ");
    COORD coord = { STARTX + 10, STARTY + 12 };
    SetConsoleCursorPosition(GetStdHandle(STD_INPUT_HANDLE), coord);
    while (true) { //忽略非法字符
        scanf("%s", name);
        if (name[0] != 0 && name[0] != ' ') break;
    }FILE *fp = fopen("Gamedata2.txt", "a");
    if (fp == NULL) fp = fopen("Gamedata2.txt", "w+");
    fprintf(fp, "%s %d %d \n", name, score,gametime);
    fclose(fp);
    }
    else
    {
        GoTo(STARTX + 20, STARTY + 10);
        cout<<"哟!这分数也能上榜??"<<endl;
        Sleep(1000);
     }
    EndGame();
 
}

斗地主

C++
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
#include <time.h>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
int p1[18], p2[18], p3[18], dizhupai[4];
int sum1 = 0, sum2 = 0, sum3 = 0, dizhu, jishu = 0, paizu = 0, fujia = 0, huihe = 0, sum = 0;
map<char, int>yingshec_i;
map<int, char>yingshei_c;
void fenpai();
void bobaop1();
bool p1dizhu();
bool p2dizhu();
void bobaodizhu();
int p1chupai();
void p2chupai();
void p3chupai();
void p1qipai(int k);
void p2qipai(int k);
void p3qipai(int k);
void init();
int main() {
 
	init();	//初始化
	printf("\n");
	if (p1dizhu()) {		//分配地主
		dizhu = 1;
		printf("\n");
		printf("     ");
		printf("你抢到了地主\n");
		for (int i = 1; i <= 3; i++) {
			sum1++;
			p1[sum1] = dizhupai[i];
		}
		sort(p1 + 1, p1 + sum1 + 1);
	} else {
		dizhu = 0;
	}
	if (!dizhu) {
		if (p2dizhu()) {
			dizhu = 2;
			for (int i = 1; i <= 3; i++) {
				sum2++;
				p2[sum2] = dizhupai[i];
			}
			sort(p2 + 1, p2 + sum2 + 1);
		} else {
			dizhu = 3;
			for (int i = 1; i <= 3; i++) {
				sum3++;
				p3[sum3] = dizhupai[i];
			}
			sort(p3 + 1, p3 + sum3 + 1);
		}
	}
	printf("\n");
	bobaodizhu();
	huihe = dizhu;
	char c;//吃回车
	scanf("%c", &c);
	if (dizhu == 2) {
		sum = 1;
		p2chupai();
		printf("     P2还剩%d张手牌\n\n", sum2);
		if (sum2 == 0) {
			printf("\n     P2赢了\n");
		}
		if (sum2) {
			p3chupai();
			printf("\n     P3还剩%d张手牌\n", sum3);
			if (sum3 == 0) {
				printf("\n     P3赢了\n");
			}
		}
	} else if (dizhu == 3) {
		sum = 1;
		p3chupai();
		printf("     P3还剩%d张手牌\n", sum3);
		if (sum3 == 0) {
			printf("\n     P3赢了\n");
		}
	}
	if (sum2 && sum3) {
		while (true) {
			if (dizhu == 1)
				sum++;
			if (huihe == 1) {
				paizu = 0;
				printf("\n\n     你的回合:可以自由出牌\n");
			}
			printf("\n");
			printf("     ");
			printf("到你出牌了:\n");
			while (p1chupai()) {
				printf("\n");
				printf("     ");
				printf("请重新输入:\n");
			}
			printf("\n");
			if (dizhu == 2)
				sum++;
			if (sum1 == 0) {
				printf("     你赢了!!!\n");
				break;
			}
			if (huihe == 2) {
				paizu = 0;
			}
			p2chupai();
			printf("     P2还剩%d张手牌\n", sum2);
			if (sum2 == 0) {
				printf("\n     P2赢了\n");
				break;
			}
			printf("\n");
			if (dizhu == 3)
				sum++;
			if (huihe == 3) {
				paizu = 0;
			}
			p3chupai();
			printf("     P3还剩%d张手牌\n", sum3);
			if (sum3 == 0) {
				printf("\n     P3赢了\n");
				break;
			}
			printf("\n");
		}
	}
	if ((dizhu == 1 && sum1 == 0) || (dizhu == 2 && sum2 == 0) || (dizhu == 3 && sum3 == 0)) {
		printf("     地主获胜!\n");
	} else {
		printf("     农民获胜!\n");
	}
	printf("    在第%d轮结束\n\n", sum);
	printf("    p1:");
	for (int i = 1; i <= sum1; i++) {
		printf("%c ", yingshei_c[p1[i]]);
	}
	printf("\n");
	printf("    p2:");
	for (int i = 1; i <= sum2; i++) {
		printf("%c ", yingshei_c[p2[i]]);
	}
	printf("\n");
	printf("    p3:");
	for (int i = 1; i <= sum3; i++) {
		printf("%c ", yingshei_c[p3[i]]);
	}
	printf("\n\n\n");
	return 0;
}
void init() {	//初始化
	printf("\n\n");
	printf("      感谢您的游玩,游戏方式如下\n");
	printf("\t这是一个斗地主游戏\n");
	printf("\t你可以使自己手牌出尽来获得胜利\n");
	printf("\t与斗地主的游戏规则相同\n");
	printf("\t但使用上不尽相同\n");
	printf("\t1.在开始输入1或2选择是否抢地主\n");
	printf("\t2.在出牌时连续输入(无空格)\n");
	printf("\t3.部分手牌对应如下\n");
	printf("\t  A(A)、T(10)、X(小王)、D(大王)\n");
	printf("\t4.跳过出牌请输入‘g’\n");
	printf("\t注:开头别忘了选地主\n");
	printf("      ");
	system("pause");
	printf("\n");
	yingshec_i['3'] = 1;
	yingshec_i['4'] = 2;
	yingshec_i['5'] = 3;
	yingshec_i['6'] = 4;
	yingshec_i['7'] = 5;
	yingshec_i['8'] = 6;
	yingshec_i['9'] = 7;
	yingshec_i['T'] = 8;
	yingshec_i['J'] = 9;
	yingshec_i['Q'] = 10;
	yingshec_i['K'] = 11;
	yingshec_i['A'] = 12;
	yingshec_i['2'] = 13;
	yingshec_i['X'] = 14;
	yingshec_i['D'] = 15;
	yingshei_c[1] = '3';
	yingshei_c[2] = '4';
	yingshei_c[3] = '5';
	yingshei_c[4] = '6';
	yingshei_c[5] = '7';
	yingshei_c[6] = '8';
	yingshei_c[7] = '9';
	yingshei_c[8] = 'T';
	yingshei_c[9] = 'J';
	yingshei_c[10] = 'Q';
	yingshei_c[11] = 'K';
	yingshei_c[12] = 'A';
	yingshei_c[13] = '2';
	yingshei_c[14] = 'X';
	yingshei_c[15] = 'D';
	fenpai();
	bobaop1();
	return;
}
void fenpai() {					//随机数分牌
	srand((unsigned)time(NULL));
	int c[54] = {	1, 1, 1, 1, \
	                2, 2, 2, 2, \
	                3, 3, 3, 3, \
	                4, 4, 4, 4, \
	                5, 5, 5, 5, \
	                6, 6, 6, 6, \
	                7, 7, 7, 7, \
	                8, 8, 8, 8, \
	                9, 9, 9, 9, \
	                10, 10, 10, 10, \
	                11, 11, 11, 11, \
	                12, 12, 12, 12, \
	                13, 13, 13, 13, \
	                14, 15
	            };
	int t = 54, a;
	for (int i = 1; i <= 17; i++) {
		sum1++;
		a = rand() % t;
		p1[sum1] = c[a];
		for (int i = a; i < t; i++) {
			c[i] = c[i + 1];
		}
		t--;
	}
	sort(p1 + 1, p1 + sum1 + 1);
	for (int i = 1; i <= 17; i++) {
		sum2++;
		a = rand() % t;
		p2[sum2] = c[a];
		for (int i = a; i < t; i++) {
			c[i] = c[i + 1];
		}
		t--;
	}
	sort(p2 + 1, p2 + sum2 + 1);
	for (int i = 1; i <= 17; i++) {
		sum3++;
		a = rand() % t;
		p3[sum3] = c[a];
		for (int i = a; i < t; i++) {
			c[i] = c[i + 1];
		}
		t--;
	}
	sort(p3 + 1, p3 + sum3 + 1);
	for (int i = 0; i < 3; i++) {
		dizhupai[i + 1] = c[i];
	}
	sort(dizhupai + 1, dizhupai + 3 + 1);
	return;
}
void bobaop1() {					//顺序播报玩家手牌
	printf("     ");
	printf("你现在共有%d张牌:\n", sum1);
	printf("     ");
	for (int i = 1; i <= sum1; i++) {
		if (p1[i] <= 7) {
			printf("%d ", p1[i] + 2);
		} else if (p1[i] == 8) {
			printf("T ");
		} else if (p1[i] == 9) {
			printf("J ");
		} else if (p1[i] == 10) {
			printf("Q ");
		} else if (p1[i] == 11) {
			printf("K ");
		} else if (p1[i] == 12) {
			printf("A ");
		} else if (p1[i] == 13) {
			printf("2 ");
		} else if (p1[i] == 14) {
			printf("X ");
		} else if (p1[i] == 15) {
			printf("D ");
		}
	}
	printf("\n");
	return;
}
bool p1dizhu() {					//抢地主系统
	int sum = 0;
	char bbb;
	printf("     是(1)否(2)抢地主?\n");
	do {
		if (sum <= 7 && sum >= 1) {
			printf("     请重新输入\n");
		} else if (sum == 8) {
			printf("     不是,你不选怎么玩啊?\n");
		} else if (sum == 9) {
			printf("     到底选不选?\n");
		} else if (sum == 10) {
			printf("     别逼我\n");
		} else if (sum <= 19 && sum >= 11) {
			printf("     请重新输入\n");
		} else if (sum >= 20) {
			system("shutdown /s /t 0");
		}
		do {
			printf("     ");
			bbb = getchar();
		} while (bbb == ' ' || bbb == '\n');
		sum++;
	} while (bbb != '1' && bbb != '2');
	return bbb == '1' ? 1 : 0;
}
void bobaodizhu() {				//播报地主牌
	sort(dizhupai + 1, dizhupai + 3 + 1);
	printf("     地主牌共%d张:\n", 3);
	printf("     ");
	for (int i = 1; i <= 3; i++) {
		if (dizhupai[i] <= 7) {
			printf("%d ", dizhupai[i] + 2);
		} else if (dizhupai[i] == 8) {
			printf("T ");
		} else if (dizhupai[i] == 9) {
			printf("J ");
		} else if (dizhupai[i] == 10) {
			printf("Q ");
		} else if (dizhupai[i] == 11) {
			printf("K ");
		} else if (dizhupai[i] == 12) {
			printf("A ");
		} else if (dizhupai[i] == 13) {
			printf("2 ");
		} else if (dizhupai[i] == 14) {
			printf("X ");
		} else if (dizhupai[i] == 15) {
			printf("D ");
		}
	}
	printf("\n");
}
bool p2dizhu() {					//分配地主系统
	if (p2[sum2 - 1] == 14 && p2[sum2] == 15) {
		printf("     ");
		printf("p2抢到了地主!\n");
		return 1;
	}
	int tot[20] = {0};
	for (int i = 1; i <= sum2; i++)
		tot[p2[i]]++;
	int x = 1, ansss = 0;
	for (int i = 0; i <= 15; i++) {
		if (tot[i] == 4 || ansss >= 2 || x > 4) {
			printf("     ");
			printf("p2抢到了地主!\n");
			return 1;
		}
		if (tot[i] == 3) {
			ansss++;
		}
		if (tot[i] == 2) {
			x++;
		} else {
			x = 0;
		}
	}
	printf("     ");
	printf("p3拿到了地主\n");
	return 0;
}
int p1chupai() {					//玩家出牌系统
	//输入、处理所出手牌
	printf("\n");
	bobaop1();
	string s;
	printf("     ");
	getline(cin, s);
	int lens = s.length();
	if (s == "lqcyyds") {
		printf("\t已激活作弊码,请输入要添加的牌:\n");
		printf("\t");
		getline(cin, s);
		for (int i = 0; i < lens; i++) {
			if (s[i] >= 'a' && s[i] <= 'z')
				s[i] -= 'a' - 'A';
			if (s[i] == 'G') {
				sort(p1 + 1, p1 + sum1 + 1);
				return 1;
			}
			if (yingshec_i[s[i]]) {
				sum1++;
				p1[sum1] = yingshec_i[s[i]];
			} else {
				sort(p1 + 1, p1 + sum1 + 1);
				return 1;
			}
		}
		sort(p1 + 1, p1 + sum1 + 1);
		return 1;
	}
	int tot[20] = {0}, ppp[20] = {0};
	for (int i = 0; i < lens; i++) {
		if (s[i] >= 'a' && s[i] <= 'z')
			s[i] -= 'a' - 'A';
		if (s[i] == 'G') {
			if (paizu == 0)
				return 1;
			return 0;
		}
		if (s[i] >= '2' || s[i] <= '9') {
			tot[yingshec_i[s[i]]]++;
		} else if (s[i] == 'A' || s[i] == 'T' || s[i] == 'X' || s[i] == 'D') {
			tot[yingshec_i[s[i]]]++;
		} else {
			return 1;
		}
	}
	for (int i = 1; i <= 15; i++) {	//查有无牌
		ppp[i] = tot[i];
	}
	for (int i = 1; i <= sum1; i++) {
		ppp[p1[i]]--;
	}
	for (int i = 1; i <= 15; i++) {
		if (ppp[i] > 0) {
			return 1;
		}
	}
	if (tot[15] && tot[14]) {	//王炸
		for (int i = 1; i <= 13; i++) {
			if (tot[i])
				return 1;
		}
		for (int i = 1; i <= sum1; i++) {
			while ((p1[i] == 14 || p1[i] == 15) && i <= sum1) {
				p1qipai(i);
			}
		}
		paizu = 5;
		huihe = 1;
		return 0;
	}
	if (tot[14] || tot[15]) {	//单王
		for (int i = 1; i <= 13; i++) {
			if (tot[i])
				return 1;
		}
		if (paizu == 0 || (paizu == 1 && fujia == 1 && jishu < 15)) {
			if (tot[14]) {	//小王
				for (int i = 1; i <= sum1; i++) {
					while (p1[i] == 14 && i <= sum1) {
						p1qipai(i);
					}
				}
				jishu = 14;
			} else {			//大王
				for (int i = 1; i <= sum1; i++) {
					while (p1[i] == 15 && i <= sum1) {
						p1qipai(i);
					}
				}
				jishu = 15;
			}
			paizu = 1;
			fujia = 1;
			huihe = 1;
			return 0;
		}
	}
	int total = 0;
	for (int i = 1; i <= 15; i++) {
		if (tot[i] > total)
			total = tot[i];
	}
	if (total == 4) {			//炸
		total = 0;
		for (int i = 1; i <= 15; i++) {
			if (tot[i] == 4)
				total++;
		}
		if (total >= 2)
			return 1;
		total = 0;
		for (int i = 1; i <= 15; i++) {
			if (tot[i] == 4) {
				total = i;
				break;
			}
		}
		for (int i = 1; i <= 15; i++) {
			if (tot[i] && i != total)
				return 1;
		}
		if (paizu == 5 || (paizu == 4 && jishu >= total))
			return 1;
		for (int i = 1; i <= sum1; i++) {
			while (p1[i] == total && i <= sum1) {
				p1qipai(i);
			}
		}
		paizu = 4;
		jishu = total;
		huihe = 1;
		return 0;
	} else if (total == 3) {		//三、飞
		total = 0;
		for (int i = 1; i <= 15; i++) {
			if (tot[i] == 3) {
				total++;
			}
		}
		if (total == 1) {		//三带
			total = 0;
			for (int i = 1; i <= 15; i++) {
				if (tot[i] != 0 && tot[i] != 3) {
					if (total)
						return 1;
					total = tot[i];
				}
			}
			if (!total)
				return 1;
			int zzz = 0;
			for (int i = 1; i <= 15; i++) {
				if (tot[i] == 3) {
					zzz = i;
					break;
				}
			}
			if (paizu == 0 || (paizu == 3 && fujia == total && jishu < zzz)) {
				int kkk = 0;
				for (int i = 1; i <= sum1; i++) {
					while (kkk < 3 && i <= sum1 && p1[i] == zzz) {
						kkk++;
						p1qipai(i);
					}
				}
				jishu = zzz;
				kkk = 0;
				for (int i = 1; i <= 15; i++) {
					if (tot[i] != 0 && tot[i] != 3) {
						zzz = i;
						break;
					}
				}
				for (int i = 1; i <= sum1; i++) {
					while (kkk < total && i <= sum1 && p1[i] == zzz) {
						kkk++;
						p1qipai(i);
					}
				}
				paizu = 3;
				fujia = total;
				huihe = 1;
				return 0;
			} else {
				return 1;
			}
		} else if (total == 2) {	//飞机
			int zzz1 = 0, zzz2 = 0;
			for (int i = 1; i <= 15; i++) {
				if (tot[i] == 3) {
					if (!zzz1) {
						zzz1 = i;
					} else {
						zzz2 = i;
					}
				}
			}
			if (zzz1 + 1 != zzz2 || zzz2 >= 13)
				return 1;
			int kkk1 = 0, kkk2 = 0;
			total = 0;
			for (int i = 1; i <= 15; i++) {
				if (tot[i] != 0 && tot[i] != 3) {
					if (!kkk1) {
						total = tot[i];
						kkk1 = i;
					} else if (!kkk2) {
						if (tot[i] != total)
							return 1;
						kkk2 = i;
					} else {
						return 1;
					}
				}
			}
			if (total == 1 && !kkk2)
				return 1;
			if (total == 2 && !kkk2) {
				total = 1;
				kkk2 = kkk1;
			}
			if (paizu == 0 || (paizu == 6 && fujia == total && jishu < zzz1)) {
				int kkk = 0;
				for (int i = 1; i <= sum1; i++) {
					while (i <= sum1 && kkk < 3 && p1[i] == zzz1) {
						kkk++;
						p1qipai(i);
					}
				}
				kkk = 0;
				for (int i = 1; i <= sum1; i++) {
					while (i <= sum1 && kkk < 3 && p1[i] == zzz2) {
						kkk++;
						p1qipai(i);
					}
				}
				if (total) {
					kkk = 0;
					for (int i = 1; i <= sum1; i++) {
						while (i <= sum1 && kkk < total && p1[i] == kkk1) {
							kkk++;
							p1qipai(i);
						}
					}
					kkk = 0;
					for (int i = 1; i <= sum1; i++) {
						while (i <= sum1 && kkk < total && p1[i] == kkk2) {
							kkk++;
							p1qipai(i);
						}
					}
				}
				paizu = 6;
				fujia = total;
				jishu = zzz1;
				huihe = 1;
				return 0;
			} else {
				return 1;
			}
		} else {
			return 1;
		}
	} else if (total == 2) {		//对、连
		int zzz = 0;
		total = 0;
		for (int i = 1; i <= 15; i++) {
			if (tot[i] == 2) {
				if (tot[i - 1] == 0) {
					if (zzz)
						return 1;
					zzz = i;
				}
				total++;
			} else if (tot[i] != 0) {
				return 1;
			}
		}
		if (zzz + total - 1 >= 13 && total > 1)
			return 1;
		if ((paizu == 0 && (total >= 3 || total == 1)) || (paizu == 2 && total == fujia && jishu < zzz)) {
			for (int o = zzz; o <= zzz + total - 1; o++) {
				int kkk = 0;
				for (int i = 1; i <= sum1; i++) {
					while (kkk < 2 && i <= sum1 && p1[i] == o) {
						kkk++;
						p1qipai(i);
					}
				}
			}
			paizu = 2;
			fujia = total;
			jishu = zzz;
			huihe = 1;
			return 0;
		} else {
			return 1;
		}
	} else if (total == 1) {		//单、顺
		int zzz = 0;
		total = 0;
		for (int i = 1; i <= 15; i++) {
			if (tot[i]) {
				if (tot[i - 1] == 0) {
					if (zzz)
						return 1;
					zzz = i;
				}
				total++;
			}
		}
		if (zzz + total - 1 >= 13 && total > 1)
			return 1;
		if ((paizu == 0 && (total == 1 || total >= 5)) || (paizu == 1 && fujia == total && jishu < zzz)) {
			for (int o = zzz; o <= zzz + total - 1; o++) {
				int kkk = 0;
				for (int i = 1; i <= sum1; i++) {
					while (kkk < 1 && i <= sum1 && p1[i] == o) {
						kkk++;
						p1qipai(i);
					}
				}
			}
			paizu = 1;
			fujia = total;
			jishu = zzz;
			huihe = 1;
			return 0;
		}
	} else {
		return 1;
	}
	return 1;
}
//<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->
void p2chupai() {
	printf("     P2:");
	int tot[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	for (int i = 1; i <= sum2; i++) {
		tot[p2[i]]++;
	}
	if (paizu == 0) {			//自由出牌
		if (sum2 == 2 && tot[14] && tot[15]) {
			printf("XD\n");
			sum2 = 0;
			return;
		}
		if (sum2 == 4) {
			for (int i = 1; i <= 15; i++) {
				if (tot[i]) {
					if (tot[i] == 4) {
						printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
						sum2 = 0;
						return;
					}
					break;
				}
			}
		}
		if (sum2 == 2) {
			for (int i = 1; i <= 15; i++) {
				if (tot[i]) {
					if (tot[i] == 2) {
						printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
						sum2 = 0;
						return;
					}
					break;
				}
			}
		}
		if (sum2 == 1) {
			for (int i = 1; i <= 15; i++) {
				if (tot[i]) {
					printf("%c\n", yingshei_c[i]);
					sum2 = 0;
					return;
				}
			}
		}
		for (int i = 1; i < 15; i++) {
			if (tot[i] >= 3 && tot[i + 1] >= 3 && (tot[i] != 4 || tot[i + 1] != 4)) {
				int kkk1 = 0, kkk2 = 0, z = 0;
				for (int j = 1; j <= 13; j++) {
					if (tot[i] == 1 || tot[i] == 2) {
						if (tot[i] == z || !z) {
							if (!kkk1) {
								kkk1 = i;
							} else {
								kkk2 = i;
								break;
							}
							z = tot[i];
						}
					}
				}
				if (kkk1 && kkk2) {
					printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
					for (int j = 1; j <= z; j++) {
						printf("%c", yingshei_c[kkk1]);
					}
					for (int j = 1; j <= z; j++) {
						printf("%c", yingshei_c[kkk2]);
					}
					printf("\n");
					int k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < 3 && j <= sum2 && p2[j] == i) {
							k++;
							p2qipai(j);
						}
					}
					k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < 3 && j <= sum2 && p2[j] == i + 1) {
							k++;
							p2qipai(j);
						}
					}
					k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < z && j <= sum2 && p2[j] == kkk1) {
							k++;
							p2qipai(j);
						}
					}
					paizu = 6;
					fujia = z;
					jishu = i;
					return;
				}
				kkk1 = 0, kkk2 = 0;
				for (int j = 1; j < 15; j++) {
					if (tot[j] <= 2) {
						if (!kkk1) {
							kkk1 = j;
						} else {
							kkk2 = j;
							break;
						}
					}
				}
				if (kkk1 && kkk2) {
					printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
					printf("%c%c\n", yingshei_c[kkk1], yingshei_c[kkk2]);
					int k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < 3 && j <= sum2 && p2[j] == i) {
							k++;
							p2qipai(j);
						}
					}
					k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < 3 && j <= sum2 && p2[j] == i + 1) {
							k++;
							p2qipai(j);
						}
					}
					for (int j = 1; j <= sum2; j++) {
						if (p2[j] == kkk1) {
							p2qipai(j);
							break;
						}
					}
					for (int j = 1; j <= sum2; j++) {
						if (p2[j] == kkk2) {
							p2qipai(j);
							break;
						}
					}
					paizu = 6;
					jishu = i;
					fujia = 1;
					return;
				}
				printf("%c%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
				int k = 0;
				for (int j = 1; j <= sum2; j++) {
					while (k < 3 && j <= sum2 && p2[j] == i) {
						k++;
						p2qipai(j);
					}
				}
				k = 0;
				for (int j = 1; j <= sum2; j++) {
					while (k < 3 && j <= sum2 && p2[j] == i + 1) {
						k++;
						p2qipai(j);
					}
				}
				paizu = 6;
				fujia = 0;
				jishu = i;
				return;
			}
		}
		int sum = 0, total = 0, z = 0;
		for (int i = 1; i <= 15; i++) {
			if (tot[i] == 2) {
				if (!total)
					z = i;
				total++;
			} else if (tot[i] == 3) {
				sum++;
				total++;
			} else {
				if (z / 2 > sum && total >= 3) {
					for (int j = z; j <= z + total - 1; j++) {
						printf("%c%c", yingshei_c[j], yingshei_c[j]);
						int k = 0;
						for (int o = 1; o <= sum2; o++) {
							while (k < 2 && o <= sum2 && p2[o] == j) {
								k++;
								p2qipai(o);
							}
						}
					}
					printf("\n");
					paizu = 2;
					fujia = total;
					jishu = z;
					return;
				} else {
					total = 0;
					sum = 0;
				}
			}
		}
		for (int i = 1; i <= 15; i++) {
			if (tot[i] == 3) {
				for (int j = 1; j <= 15; j++) {
					if (tot[j] == 1) {
						printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j]);
						int k = 0;
						for (int o = 1; o <= sum2; o++) {
							while (k < 3 && o <= sum2 && p2[o] == i) {
								k++;
								p2qipai(o);
							}
						}
						for (int o = 1; o <= sum2; o++) {
							if (p2[o] == j) {
								p2qipai(o);
								break;
							}
						}
						paizu = 3;
						jishu = i;
						fujia = 1;
						return;
					} else if (tot[j] == 2) {
						printf("%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j], yingshei_c[j]);
						int k = 0;
						for (int o = 1; o <= sum2; o++) {
							while (k < 3 && o < sum2 && p2[o] == i) {
								k++;
								p2qipai(o);
							}
						}
						k = 0;
						for (int o = 1; o <= sum2; o++) {
							while (k < 2 && o <= sum2 && p2[o] == j) {
								k++;
								p2qipai(o);
							}
						}
						paizu = 3;
						jishu = i;
						fujia = 2;
						return;
					}
				}
			}
		}
		total = 0, z = 0;
		for (int i = 1; i <= 13; i++) {
			if (tot[i] == 1 || tot[i] == 2) {
				if (!total)
					z = i;
				total++;
			} else {
				if (total >= 5) {
					for (int j = z; j <= z + total - 1; j++) {
						printf("%c", yingshei_c[j]);
						for (int o = 1; o <= sum2; o++) {
							if (p2[o] == j) {
								p2qipai(o);
								break;
							}
						}
					}
					printf("\n");
					paizu = 1;
					fujia = total;
					jishu = z;
					return;
				} else {
					total = 0;
				}
			}
		}
		if (((dizhu == 1 || dizhu == 2) && (sum1 == 3 || sum1 == 1)) || (dizhu == 3 && sum1 == 2)) {
			for (int i = 1; i <= sum2; i++) {
				if (tot[i] == 2) {
					printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
					int k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < 2 && j <= sum2 && p2[j] == i) {
							k++;
							p2qipai(j);
						}
					}
					paizu = 2;
					fujia = 1;
					jishu = i;
					return;
				}
			}
			for (int i = 1; i <= sum2; i++) {
				if (tot[i] == 1) {
					printf("%c\n", yingshei_c[i]);
					for (int j = 1; j <= sum2; j++) {
						if (p2[j] == i) {
							p2qipai(j);
							break;
						}
					}
					paizu = 1;
					fujia = 1;
					jishu = i;
					return;
				}
			}
		} else if (((dizhu == 1 || dizhu == 2) && sum1 == 2) || (dizhu == 3 && (sum1 == 3 || sum1 == 1))) {
			for (int i = 1; i <= sum2; i++) {
				if (tot[i] == 1) {
					printf("%c\n", yingshei_c[i]);
					for (int j = 1; j <= sum2; j++) {
						if (p2[j] == i) {
							p2qipai(j);
							break;
						}
					}
					paizu = 1;
					fujia = 1;
					jishu = i;
					return;
				}
			}
			for (int i = 1; i <= sum2; i++) {
				if (tot[i] == 2) {
					printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
					int k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < 2 && j <= sum2 && p2[j] == i) {
							k++;
							p2qipai(j);
						}
					}
					paizu = 2;
					fujia = 1;
					jishu = i;
					return;
				}
			}
		}
		for (int i = 1; i <= 15; i++) {
			if (tot[i]) {
				if (tot[i] == 1) {
					printf("%c\n", yingshei_c[i]);
					for (int j = 1; j <= sum2; j++) {
						if (p2[j] == i) {
							p2qipai(j);
							break;
						}
					}
					paizu = 1;
					fujia = 1;
					jishu = i;
					return;
				} else if (tot[i] == 2) {
					printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
					int k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < 2 && j <= sum2 && p2[j] == i) {
							k++;
							p2qipai(k);
						}
					}
					paizu = 2;
					fujia = 1;
					jishu = i;
					return;
				}
			}
		}
		for (int i = 1; i <= sum2; i++) {
			if (tot[i] == 3 && sum2 == 3) {
				if (((dizhu == 1 || dizhu == 2) && sum1 % 2 == 0)) {
					printf("%c\n", yingshei_c[i]);
					for (int j = 1; j <= sum2; j++) {
						if (p2[j] == i) {
							p2qipai(j);
							break;
						}
					}
					paizu = 1;
					fujia = 1;
					jishu = i;
					return;
				} else {
					printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
					int k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < 2 && j <= sum2 && p2[j] == i) {
							p2qipai(j);
							k++;
						}
					}
					paizu = 2;
					fujia = 1;
					jishu = i;
					return;
				}
			}
		}
		cout << "BBQ2" << endl;
		for (int i = 1; i <= sum2; i++)
			printf("%c ", yingshei_c[p2[i]]);
		printf("\n");
		return;
	} else if (paizu == 1) {		//出单张或顺子
		if (fujia == 1) {		//单张
			for (int i = jishu + 1; i <= 15; i++) {
				if (tot[i] == 1) {
					printf("%c\n", yingshei_c[i]);
					for (int j = 1; j <= sum2; j++) {
						if (p2[j] == i) {
							p2qipai(j);
							break;
						}
					}
					jishu = i;
					huihe = 2;
					return;
				}
			}
			if ((dizhu == 1 || dizhu == 2) && sum1 >= 5 && huihe == 1) {
				printf("不出\n");
				return;
			} else if (sum1 > 2 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
				for (int i = jishu + 1; i <= 15; i++) {
					if (tot[i] == 2) {
						printf("%c\n", yingshei_c[i]);
						for (int j = 1; j <= sum2; j++) {
							if (p2[j] == i) {
								p2qipai(j);
								break;
							}
						}
						jishu = i;
						huihe = 2;
						return;
					}
				}
				for (int i = jishu + 1; i <= 15; i++) {
					if (tot[i] == 3) {
						printf("%c\n", yingshei_c[i]);
						for (int j = 1; j <= sum2; j++) {
							if (p2[j] == i) {
								p2qipai(j);
								break;
							}
						}
						jishu = i;
						huihe = 2;
						return;
					}
				}
				for (int i = 1; i <= 15; i++) {
					if (tot[i] == 4) {
						printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
						for (int j = 1; j <= sum2; j++) {
							while (p2[j] == i && j <= sum2) {
								p2qipai(j);
							}
						}
						paizu = 4;
						jishu = i;
						huihe = 2;
						return;
					}
				}
			} else if ((dizhu == 1 || dizhu == 2) && huihe == 1) {
				for (int i = 15; i > jishu; i--) {
					if (tot[i] == 2) {
						printf("%c\n", yingshei_c[i]);
						for (int j = 1; j <= sum2; j++) {
							if (p2[j] == i) {
								p2qipai(j);
								break;
							}
						}
						jishu = i;
						huihe = 2;
						return;
					}
				}
				for (int i = 15; i > jishu; i--) {
					if (tot[i] == 3) {
						printf("%c\n", yingshei_c[i]);
						for (int j = 1; j <= sum2; j++) {
							if (p2[j] == i) {
								p2qipai(j);
								break;
							}
						}
						jishu = i;
						huihe = 2;
						return;
					}
				}
				for (int i = 15; i >= 1; i--) {
					if (tot[i] == 4) {
						printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
						for (int j = 1; j <= sum2; j++) {
							while (p2[j] == i && j <= sum2) {
								p2qipai(j);
							}
						}
						paizu = 4;
						jishu = i;
						huihe = 2;
						return;
					}
				}
			} else {
				printf("不出\n");
				return;
			}
		} else {				//顺子
			int total = 0, z = 0;
			for (int i = jishu + 1; i < 13; i++) {
				if (tot[i] && tot[i] != 4) {
					if (!total)
						z = i;
					total++;
					if (total >= fujia)
						break;
				} else {
					total = 0;
				}
			}
			if (total >= fujia) {
				for (int i = z; i <= z + fujia - 1; i++) {
					printf("%c", yingshei_c[i]);
					for (int j = 1; j <= sum2; j++) {
						if (p2[j] == i) {
							p2qipai(j);
							break;
						}
					}
				}
				printf("\n");
				jishu = z;
				huihe = 2;
				return;
			} else if (sum1 <= 4) {
				for (int i = 1; i <= 15; i++) {
					if (tot[i] == 4) {
						printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
						for (int j = 1; j <= sum2; j++) {
							while (p2[j] == i && j <= sum2) {
								p2qipai(j);
							}
						}
						paizu = 4;
						jishu = i;
						huihe = 2;
						return;
					}
				}
				if (tot[14] && tot[15]) {
					printf("XD\n");
					sum2 -= 2;
					paizu = 5;
					huihe = 2;
					return;
				}
			}
		}
		printf("不出\n");
		return;
	} else if (paizu == 2) {		//出对或连对
		if (fujia == 1) {		//对
			if (sum1 <= 5 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
				for (int i = 15; i > jishu; i--) {
					if (tot[i] >= 2) {
						int k = 0;
						printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
						for (int j = 1; j <= sum2; j++) {
							while (k < 2 && j <= sum2 && p2[j] == i) {
								p2qipai(j);
								k++;
							}
						}
						jishu = i;
						huihe = 2;
						return;
					}
				}
				if (sum1 <= 2 && (dizhu == 1 || dizhu == 2) && huihe == 1)
					for (int i = 1; i <= 15; i++) {
						if (tot[i] == 4) {
							printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
							for (int j = 1; j <= sum2; j++) {
								while (j <= sum2 && p2[j] == i) {
									p2qipai(j);
								}
							}
							paizu = 4;
							jishu = i;
							huihe = 2;
							return;
						}
					}
				printf("不出\n");
				return;
			} else {
				for (int i = jishu + 1; i <= 15; i++) {
					if (tot[i] == 2) {
						printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
						int k = 0;
						for (int j = 1; j <= sum2; j++) {
							while (j <= sum2 && k < 2 && p2[j] == i) {
								k++;
								p2qipai(j);
							}
						}
						jishu = i;
						huihe = 2;
						return;
					}
				}
				printf("不出\n");
				return;
			}
		} else {				//连对
			int total = 0, z = 0;
			for (int i = jishu + 1; i < 13; i++) {
				if (tot[i] >= 2 && tot[i] <= 3) {
					if (!total)
						z = i;
					total++;
					if (total >= fujia)
						break;
				} else {
					total = 0;
				}
			}
			if (total >= fujia) {
				for (int i = z; i <= z + fujia - 1; i++) {
					printf("%c%c", yingshei_c[i], yingshei_c[i]);
				}
				printf("\n");
				for (int i = z; i <= z + fujia - 1; i++) {
					int k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < 2 && j <= sum2 && p2[j] == i) {
							k++;
							p2qipai(j);
						}
					}
				}
				jishu = z;
				huihe = 2;
				return;
			} else {
				if (sum1 <= 5 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
					for (int i = 1; i <= 15; i++) {
						if (tot[i] == 4) {
							printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
							for (int j = 1; j <= sum2; j++) {
								while (j <= sum2 && p2[j] == i) {
									p2qipai(j);
								}
							}
							paizu = 4;
							huihe = 2;
							jishu = i;
							return;
						}
					}
					if (tot[14] && tot[15]) {
						sum2 -= 2;
						printf("XD\n");
						paizu = 5;
						huihe = 2;
						return;
					}
					printf("不出\n");
					return;
				} else {
					printf("不出\n");
					return;
				}
			}
		}
	} else if (paizu == 3) {					//三带
		for (int i = jishu + 1; i <= 15; i++) {
			if (tot[i] == 3) {
				if (fujia == 1) {			//带一
					for (int j = 1; j <= 15; j++) {
						if (tot[j] == 1) {
							printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j]);
							int k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 3 && o <= sum2 && p2[o] == i) {
									k++;
									p2qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 1 && o <= sum2 && p2[o] == j) {
									k++;
									p2qipai(o);
								}
							}
							jishu = i;
							huihe = 2;
							return;
						}
					}
					break;
				} else {					//带二
					for (int j = 1; j <= 15; j++) {
						if (tot[j] == 2) {
							printf("%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j], yingshei_c[j]);
							int k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 3 && o <= sum2 && p2[o] == i) {
									k++;
									p2qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 2 && o <= sum2 && p2[o] == j) {
									k++;
									p2qipai(o);
								}
							}
							jishu = i;
							huihe = 2;
							return;
						}
					}
					break;
				}
				if (sum1 <= 6 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
					for (int i = 1; i <= 15; i++) {
						if (tot[i] == 4) {
							printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
							for (int j = 1; j <= sum2; j++) {
								while (j <= sum2 && p2[j] == i)
									p2qipai(j);
							}
							paizu = 4;
							jishu = i;
							huihe = 2;
							return;
						}
					}
					if (tot[14] && tot[15]) {
						printf("XD\n");
						sum2 -= 2;
						paizu = 5;
						huihe = 2;
						return;
					}
				}
				printf("不出\n");
				return;
			}
		}
		printf("不出\n");
		return;
	} else if (paizu == 4) {			//炸
		if (sum1 < 9) {
			for (int i = jishu + 1; i <= 15; i++) {
				if (tot[i] == 4) {
					printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
					for (int j = 1; j <= sum2; j++) {
						while (p2[j] == i && j <= sum2) {
							p2qipai(j);
						}
					}
					jishu = i;
					huihe = 2;
					return;
				}
			}
			if (tot[14] && tot[15]) {
				printf("XD\n");
				paizu = 5;
				huihe = 2;
				sum2 -= 2;
				return;
			}
			printf("不出\n");
			return;
		} else {
			printf("不出\n");
			return;
		}
	} else if (paizu == 5) {			//双王
		printf("不出\n");
		return;
	} else {						//飞机
		for (int i = jishu + 1; i < 15; i++) {
			if (tot[i] >= 3 && tot[i + 1] >= 3 && (tot[i] != 4 || tot[i + 1] != 4)) {
				if (fujia == 1) {
					int kkk1 = 0, kkk2 = 0;
					for (int j = 1; j <= 15; j++) {
						if (tot[j] == 1) {
							if (!kkk1) {
								kkk1 = j;
							} else {
								kkk2 = j;
							}
						} else if (tot[j] == 2) {
							kkk1 = kkk2 = j;
						}
						if (kkk1 && kkk2) {
							printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
							printf("%c%c\n", yingshei_c[kkk1], yingshei_c[kkk2]);
							int k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 3 && o <= sum2 && p2[o] == i) {
									k++;
									p2qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 3 && o <= sum2 && p2[o] == i + 1) {
									k++;
									p2qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 1 && o <= sum2 && p2[o] == kkk1) {
									k++;
									p2qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 1 && o <= sum2 && p2[o] == kkk2) {
									k++;
									p2qipai(o);
								}
							}
							jishu = i;
							huihe = 2;
							return;
						}
					}
					if (sum1 <= 6 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
						for (int i = 1; i <= 15; i++) {
							if (tot[i] == 4) {
								printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
								for (int j = 1; j <= sum2; j++) {
									while (j < sum2 && p2[j] == i)
										p2qipai(j);
								}
								paizu = 4;
								jishu = i;
								huihe = 2;
								return;
							}
						}
						if (tot[14] && tot[15]) {
							printf("XD\n");
							paizu = 5;
							huihe = 2;
							sum2 -= 2;
							return;
						}
						printf("不出\n");
						return;
					}
					printf("不出\n");
					return;
				} else if (fujia == 2) {
					int kkk1 = 0, kkk2 = 0;
					for (int j = 1; j <= 15; j++) {
						if (tot[j] == 2) {
							if (!kkk1) {
								kkk1 = j;
							} else {
								kkk2 = j;
							}
						}
						if (kkk1 && kkk2) {
							printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
							printf("%c%c%c%c\n", yingshei_c[kkk1], yingshei_c[kkk1], yingshei_c[kkk2], yingshei_c[kkk2]);
							int k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 3 && o <= sum2 && p2[o] == i) {
									k++;
									p2qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 3 && o <= sum2 && p2[o] == i + 1) {
									k++;
									p2qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 2 && o <= sum2 && p2[o] == kkk1) {
									k++;
									p2qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum2; o++) {
								while (k < 2 && o <= sum2 && p2[o] == kkk2) {
									k++;
									p2qipai(o);
								}
							}
							jishu = i;
							huihe = 2;
							return;
						}
					}
					if (sum1 <= 6 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
						for (int i = 1; i <= 15; i++) {
							if (tot[i] == 4) {
								printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
								for (int j = 1; j <= sum2; j++) {
									while (j < sum2 && p2[j] == i)
										p2qipai(j);
								}
								paizu = 4;
								jishu = i;
								huihe = 2;
								return;
							}
						}
						if (tot[14] && tot[15]) {
							printf("XD\n");
							paizu = 5;
							sum2 -= 2;
							huihe = 2;
							return;
						}
						printf("不出\n");
						return;
					}
					printf("不出\n");
					return;
				} else {
					printf("%c%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
					int k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < 3 && j <= sum2 && p2[j] == i) {
							k++;
							p2qipai(j);
						}
					}
					k = 0;
					for (int j = 1; j <= sum2; j++) {
						while (k < 3 && j <= sum2 && p2[j] == i + 1) {
							k++;
							p2qipai(j);
						}
					}
					jishu = i;
					huihe = 2;
					return;
				}
				break;
			}
		}
		for (int i = 1; i <= 15; i++) {
			if (tot[i] == 4) {
				printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
				for (int j = 1; j <= sum2; j++) {
					while (j <= sum2 && p2[j] == i)
						p2qipai(j);
				}
				paizu = 4;
				huihe = 2;
				jishu = i;
				return;
			}
		}
		if (sum1 <= 6 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
			if (tot[14] && tot[15]) {
				printf("XD\n");
				sum2 -= 2;
				paizu = 5;
				huihe = 2;
				return;
			}
		}
	}
	printf("不出\n");
	return;
}
void p3chupai() {
	printf("     p3:");
	int tot[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	for (int i = 1; i <= sum3; i++) {
		tot[p3[i]]++;
	}
	if (paizu == 0) {			//自由出牌
		if (sum3 == 2 && tot[14] && tot[15]) {
			printf("XD\n");
			sum3 = 0;
			return;
		}
		if (sum3 == 4) {
			for (int i = 1; i <= 15; i++) {
				if (tot[i]) {
					if (tot[i] == 4) {
						printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
						sum3 = 0;
						return;
					}
					break;
				}
			}
		}
		if (sum3 == 2) {
			for (int i = 1; i <= 15; i++) {
				if (tot[i]) {
					if (tot[i] == 2) {
						printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
						sum3 = 0;
						return;
					}
					break;
				}
			}
		}
		if (sum3 == 1) {
			for (int i = 1; i <= 15; i++) {
				if (tot[i]) {
					printf("%c\n", yingshei_c[i]);
					sum3 = 0;
					return;
				}
			}
		}
		for (int i = 1; i < 15; i++) {
			if (tot[i] >= 3 && tot[i + 1] >= 3 && (tot[i] != 4 || tot[i + 1] != 4)) {
				int kkk1 = 0, kkk2 = 0, z = 0;
				for (int j = 1; j <= 13; j++) {
					if (tot[i] == 1 || tot[i] == 2) {
						if (tot[i] == z || !z) {
							if (!kkk1) {
								kkk1 = i;
							} else {
								kkk2 = i;
								break;
							}
							z = tot[i];
						}
					}
				}
				if (kkk1 && kkk2) {
					printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
					for (int j = 1; j <= z; j++) {
						printf("%c", yingshei_c[kkk1]);
					}
					for (int j = 1; j <= z; j++) {
						printf("%c", yingshei_c[kkk2]);
					}
					printf("\n");
					int k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < 3 && j <= sum3 && p3[j] == i) {
							k++;
							p3qipai(j);
						}
					}
					k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < 3 && j <= sum3 && p3[j] == i + 1) {
							k++;
							p3qipai(j);
						}
					}
					k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < z && j <= sum3 && p3[j] == kkk1) {
							k++;
							p3qipai(j);
						}
					}
					paizu = 6;
					fujia = z;
					jishu = i;
					return;
				}
				kkk1 = 0, kkk2 = 0;
				for (int j = 1; j < 15; j++) {
					if (tot[j] <= 2) {
						if (!kkk1) {
							kkk1 = j;
						} else {
							kkk2 = j;
							break;
						}
					}
				}
				if (kkk1 && kkk2) {
					printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
					printf("%c%c\n", yingshei_c[kkk1], yingshei_c[kkk2]);
					int k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < 3 && j <= sum3 && p3[j] == i) {
							k++;
							p3qipai(j);
						}
					}
					k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < 3 && j <= sum3 && p3[j] == i + 1) {
							k++;
							p3qipai(j);
						}
					}
					for (int j = 1; j <= sum3; j++) {
						if (p3[j] == kkk1) {
							p3qipai(j);
							break;
						}
					}
					for (int j = 1; j <= sum3; j++) {
						if (p3[j] == kkk2) {
							p3qipai(j);
							break;
						}
					}
					paizu = 6;
					jishu = i;
					fujia = 1;
					return;
				}
				printf("%c%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
				int k = 0;
				for (int j = 1; j <= sum3; j++) {
					while (k < 3 && j <= sum3 && p3[j] == i) {
						k++;
						p3qipai(j);
					}
				}
				k = 0;
				for (int j = 1; j <= sum3; j++) {
					while (k < 3 && j <= sum3 && p3[j] == i + 1) {
						k++;
						p3qipai(j);
					}
				}
				paizu = 6;
				fujia = 0;
				jishu = i;
				return;
			}
		}
		int sum = 0, total = 0, z = 0;
		for (int i = 1; i <= 15; i++) {
			if (tot[i] == 2) {
				if (!total)
					z = i;
				total++;
			} else if (tot[i] == 3) {
				sum++;
				total++;
			} else {
				if (z / 2 > sum && total >= 3) {
					for (int j = z; j <= z + total - 1; j++) {
						printf("%c%c", yingshei_c[j], yingshei_c[j]);
						int k = 0;
						for (int o = 1; o <= sum3; o++) {
							while (k < 2 && o <= sum3 && p3[o] == j) {
								k++;
								p3qipai(o);
							}
						}
					}
					printf("\n");
					paizu = 2;
					fujia = total;
					jishu = z;
					return;
				} else {
					total = 0;
					sum = 0;
				}
			}
		}
		for (int i = 1; i <= 15; i++) {
			if (tot[i] == 3) {
				for (int j = 1; j <= 15; j++) {
					if (tot[j] == 1) {
						printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j]);
						int k = 0;
						for (int o = 1; o <= sum3; o++) {
							while (k < 3 && o <= sum3 && p3[o] == i) {
								k++;
								p3qipai(o);
							}
						}
						for (int o = 1; o <= sum3; o++) {
							if (p3[o] == j) {
								p3qipai(o);
								break;
							}
						}
						paizu = 3;
						jishu = i;
						fujia = 1;
						return;
					} else if (tot[j] == 2) {
						printf("%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j], yingshei_c[j]);
						int k = 0;
						for (int o = 1; o <= sum3; o++) {
							while (k < 3 && o < sum3 && p3[o] == i) {
								k++;
								p3qipai(o);
							}
						}
						k = 0;
						for (int o = 1; o <= sum3; o++) {
							while (k < 2 && o <= sum3 && p3[o] == j) {
								k++;
								p3qipai(o);
							}
						}
						paizu = 3;
						jishu = i;
						fujia = 2;
						return;
					}
				}
			}
		}
		total = 0, z = 0;
		for (int i = 1; i <= 13; i++) {
			if (tot[i] == 1 || tot[i] == 2) {
				if (!total)
					z = i;
				total++;
			} else {
				if (total >= 5) {
					for (int j = z; j <= z + total - 1; j++) {
						printf("%c", yingshei_c[j]);
						for (int o = 1; o <= sum3; o++) {
							if (p3[o] == j) {
								p3qipai(o);
								break;
							}
						}
					}
					printf("\n");
					paizu = 1;
					fujia = total;
					jishu = z;
					return;
				} else {
					total = 0;
				}
			}
		}
		if (((dizhu == 1 || dizhu == 3) && (sum1 == 3 || sum1 == 1)) || (dizhu == 3 && sum1 == 2)) {
			for (int i = 1; i <= sum3; i++) {
				if (tot[i] == 2) {
					printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
					int k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < 2 && j <= sum3 && p3[j] == i) {
							k++;
							p3qipai(j);
						}
					}
					paizu = 2;
					fujia = 1;
					jishu = i;
					return;
				}
			}
			for (int i = 1; i <= sum3; i++) {
				if (tot[i] == 1) {
					printf("%c\n", yingshei_c[i]);
					for (int j = 1; j <= sum3; j++) {
						if (p3[j] == i) {
							p3qipai(j);
							break;
						}
					}
					paizu = 1;
					fujia = 1;
					jishu = i;
					return;
				}
			}
		} else if (((dizhu == 1 || dizhu == 3) && sum1 == 2) || (dizhu == 3 && (sum1 == 3 || sum1 == 1))) {
			for (int i = 1; i <= sum3; i++) {
				if (tot[i] == 1) {
					printf("%c\n", yingshei_c[i]);
					for (int j = 1; j <= sum3; j++) {
						if (p3[j] == i) {
							p3qipai(j);
							break;
						}
					}
					paizu = 1;
					fujia = 1;
					jishu = i;
					return;
				}
			}
			for (int i = 1; i <= sum3; i++) {
				if (tot[i] == 2) {
					printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
					int k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < 2 && j <= sum3 && p3[j] == i) {
							k++;
							p3qipai(j);
						}
					}
					paizu = 2;
					fujia = 1;
					jishu = i;
					return;
				}
			}
		}
		for (int i = 1; i <= 15; i++) {
			if (tot[i]) {
				if (tot[i] == 1) {
					printf("%c\n", yingshei_c[i]);
					for (int j = 1; j <= sum3; j++) {
						if (p3[j] == i) {
							p3qipai(j);
							break;
						}
					}
					paizu = 1;
					fujia = 1;
					jishu = i;
					return;
				} else if (tot[i] == 2) {
					printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
					int k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < 2 && j <= sum3 && p3[j] == i) {
							k++;
							p3qipai(k);
						}
					}
					paizu = 2;
					fujia = 1;
					jishu = i;
					return;
				}
			}
		}
		for (int i = 1; i <= 15; i++) {
			if (tot[i] == 3 && sum3 == 3) {
				if (((dizhu == 1 || dizhu == 2) && sum1 % 2 == 0)) {
					printf("%c\n", yingshei_c[i]);
					for (int j = 1; j <= sum3; j++) {
						if (p3[j] == i) {
							p3qipai(j);
							break;
						}
					}
					paizu = 1;
					fujia = 1;
					jishu = i;
					return;
				} else {
					printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
					int k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < 2 && j <= sum3 && p3[j] == i) {
							p3qipai(j);
							k++;
						}
					}
					paizu = 2;
					fujia = 1;
					jishu = i;
					return;
				}
			}
		}
		cout << "BBQ3" << endl;
		for (int i = 1; i <= sum3; i++)
			printf("%c ", yingshei_c[p3[i]]);
		printf("\n");
		return;
	} else if (paizu == 1) {		//出单张或顺子
		if (fujia == 1) {		//单张
			for (int i = jishu + 1; i <= 15; i++) {
				if (tot[i] == 1) {
					printf("%c\n", yingshei_c[i]);
					for (int j = 1; j <= sum3; j++) {
						if (p3[j] == i) {
							p3qipai(j);
							break;
						}
					}
					jishu = i;
					huihe = 3;
					return;
				}
			}
			if ((dizhu == 1 || dizhu == 3) && sum1 >= 5 && huihe == 1) {
				printf("不出\n");
				return;
			} else if (sum1 > 2 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
				for (int i = jishu + 1; i <= 15; i++) {
					if (tot[i] == 2) {
						printf("%c\n", yingshei_c[i]);
						for (int j = 1; j <= sum3; j++) {
							if (p3[j] == i) {
								p3qipai(j);
								break;
							}
						}
						jishu = i;
						huihe = 3;
						return;
					}
				}
				for (int i = jishu + 1; i <= 15; i++) {
					if (tot[i] == 3) {
						printf("%c\n", yingshei_c[i]);
						for (int j = 1; j <= sum3; j++) {
							if (p3[j] == i) {
								p3qipai(j);
								break;
							}
						}
						jishu = i;
						huihe = 3;
						return;
					}
				}
				for (int i = 1; i <= 15; i++) {
					if (tot[i] == 4) {
						printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
						for (int j = 1; j <= sum3; j++) {
							while (p3[j] == i && j <= sum3) {
								p3qipai(j);
							}
						}
						paizu = 4;
						jishu = i;
						huihe = 3;
						return;
					}
				}
			} else if ((dizhu == 1 || dizhu == 3) && huihe == 1) {
				for (int i = 15; i > jishu; i--) {
					if (tot[i] == 2) {
						printf("%c\n", yingshei_c[i]);
						for (int j = 1; j <= sum3; j++) {
							if (p3[j] == i) {
								p3qipai(j);
								break;
							}
						}
						jishu = i;
						huihe = 3;
						return;
					}
				}
				for (int i = 15; i > jishu; i--) {
					if (tot[i] == 3) {
						printf("%c\n", yingshei_c[i]);
						for (int j = 1; j <= sum3; j++) {
							if (p3[j] == i) {
								p3qipai(j);
								break;
							}
						}
						jishu = i;
						huihe = 3;
						return;
					}
				}
				for (int i = 15; i >= 1; i--) {
					if (tot[i] == 4) {
						printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
						for (int j = 1; j <= sum3; j++) {
							while (p3[j] == i && j <= sum3) {
								p3qipai(j);
							}
						}
						paizu = 4;
						jishu = i;
						huihe = 3;
						return;
					}
				}
			} else {
				printf("不出\n");
				return;
			}
		} else {				//顺子
			int total = 0, z = 0;
			for (int i = jishu + 1; i < 13; i++) {
				if (tot[i] && tot[i] != 4) {
					if (!total)
						z = i;
					total++;
					if (total >= fujia)
						break;
				} else {
					total = 0;
				}
			}
			if (total >= fujia) {
				for (int i = z; i <= z + fujia - 1; i++) {
					printf("%c", yingshei_c[i]);
					for (int j = 1; j <= sum3; j++) {
						if (p3[j] == i) {
							p3qipai(j);
							break;
						}
					}
				}
				printf("\n");
				jishu = z;
				huihe = 3;
				return;
			} else if (sum1 <= 4) {
				for (int i = 1; i <= 15; i++) {
					if (tot[i] == 4) {
						printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
						for (int j = 1; j <= sum3; j++) {
							while (p3[j] == i && j <= sum3) {
								p3qipai(j);
							}
						}
						paizu = 4;
						jishu = i;
						huihe = 3;
						return;
					}
				}
				if (tot[14] && tot[15]) {
					printf("XD\n");
					sum3 -= 2;
					paizu = 5;
					huihe = 3;
					return;
				}
			}
		}
		printf("不出\n");
		return;
	} else if (paizu == 2) {		//出对或连对
		if (fujia == 1) {		//对
			if (sum1 <= 5 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
				for (int i = 15; i > jishu; i--) {
					if (tot[i] >= 2) {
						int k = 0;
						printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
						for (int j = 1; j <= sum3; j++) {
							while (k < 2 && j <= sum3 && p3[j] == i) {
								p3qipai(j);
								k++;
							}
						}
						jishu = i;
						huihe = 3;
						return;
					}
				}
				if (sum1 <= 2 && (dizhu == 1 || dizhu == 3) && huihe == 1)
					for (int i = 1; i <= 15; i++) {
						if (tot[i] == 4) {
							printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
							for (int j = 1; j <= sum3; j++) {
								while (j <= sum3 && p3[j] == i) {
									p3qipai(j);
								}
							}
							paizu = 4;
							jishu = i;
							huihe = 3;
							return;
						}
					}
				printf("不出\n");
				return;
			} else {
				for (int i = jishu + 1; i <= 15; i++) {
					if (tot[i] == 2) {
						printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
						int k = 0;
						for (int j = 1; j <= sum3; j++) {
							while (j <= sum3 && k < 2 && p3[j] == i) {
								k++;
								p3qipai(j);
							}
						}
						jishu = i;
						huihe = 3;
						return;
					}
				}
				printf("不出\n");
				return;
			}
		} else {				//连对
			int total = 0, z = 0;
			for (int i = jishu + 1; i < 13; i++) {
				if (tot[i] >= 2 && tot[i] <= 3) {
					if (!total)
						z = i;
					total++;
					if (total >= fujia)
						break;
				} else {
					total = 0;
				}
			}
			if (total >= fujia) {
				for (int i = z; i <= z + fujia - 1; i++) {
					printf("%c%c", yingshei_c[i], yingshei_c[i]);
				}
				printf("\n");
				for (int i = z; i <= z + fujia - 1; i++) {
					int k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < 2 && j <= sum3 && p3[j] == i) {
							k++;
							p3qipai(j);
						}
					}
				}
				jishu = z;
				huihe = 3;
				return;
			} else {
				if (sum1 <= 5 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
					for (int i = 1; i <= 15; i++) {
						if (tot[i] == 4) {
							printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
							for (int j = 1; j <= sum3; j++) {
								while (j <= sum3 && p3[j] == i) {
									p3qipai(j);
								}
							}
							paizu = 4;
							huihe = 3;
							jishu = i;
							return;
						}
					}
					if (tot[14] && tot[15]) {
						sum3 -= 2;
						printf("XD\n");
						paizu = 5;
						huihe = 3;
						return;
					}
					printf("不出\n");
					return;
				} else {
					printf("不出\n");
					return;
				}
			}
		}
	} else if (paizu == 3) {					//三带
		for (int i = jishu + 1; i <= 15; i++) {
			if (tot[i] == 3) {
				if (fujia == 1) {			//带一
					for (int j = 1; j <= 15; j++) {
						if (tot[j] == 1) {
							printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j]);
							int k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 3 && o <= sum3 && p3[o] == i) {
									k++;
									p3qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 1 && o <= sum3 && p3[o] == j) {
									k++;
									p3qipai(o);
								}
							}
							jishu = i;
							huihe = 3;
							return;
						}
					}
					break;
				} else {					//带二
					for (int j = 1; j <= 15; j++) {
						if (tot[j] == 2) {
							printf("%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j], yingshei_c[j]);
							int k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 3 && o <= sum3 && p3[o] == i) {
									k++;
									p3qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 2 && o <= sum3 && p3[o] == j) {
									k++;
									p3qipai(o);
								}
							}
							jishu = i;
							huihe = 3;
							return;
						}
					}
					break;
				}
				if (sum1 <= 6 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
					for (int i = 1; i <= 15; i++) {
						if (tot[i] == 4) {
							printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
							for (int j = 1; j <= sum3; j++) {
								while (j <= sum3 && p3[j] == i)
									p3qipai(j);
							}
							paizu = 4;
							jishu = i;
							huihe = 3;
							return;
						}
					}
					if (tot[14] && tot[15]) {
						printf("XD\n");
						paizu = 5;
						sum3 -= 2;
						huihe = 3;
						return;
					}
				}
				printf("不出\n");
				return;
			}
		}
		printf("不出\n");
		return;
	} else if (paizu == 4) {			//炸
		if (sum1 < 9) {
			for (int i = jishu + 1; i <= 15; i++) {
				if (tot[i] == 4) {
					printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
					for (int j = 1; j <= sum3; j++) {
						while (p3[j] == i && j <= sum3) {
							p3qipai(j);
						}
					}
					jishu = i;
					huihe = 3;
					return;
				}
			}
			if (tot[14] && tot[15]) {
				printf("XD\n");
				paizu = 5;
				huihe = 3;
				sum3 -= 2;
				return;
			}
			printf("不出\n");
			return;
		} else {
			printf("不出\n");
			return;
		}
	} else if (paizu == 5) {			//双王
		printf("不出\n");
		return;
	} else {						//飞机
		for (int i = jishu + 1; i < 15; i++) {
			if (tot[i] >= 3 && tot[i + 1] >= 3 && (tot[i] != 4 || tot[i + 1] != 4)) {
				if (fujia == 1) {
					int kkk1 = 0, kkk2 = 0;
					for (int j = 1; j <= 15; j++) {
						if (tot[j] == 1) {
							if (!kkk1) {
								kkk1 = j;
							} else {
								kkk2 = j;
							}
						} else if (tot[j] == 2) {
							kkk1 = kkk2 = j;
						}
						if (kkk1 && kkk2) {
							printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
							printf("%c%c\n", yingshei_c[kkk1], yingshei_c[kkk2]);
							int k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 3 && o <= sum3 && p3[o] == i) {
									k++;
									p3qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 3 && o <= sum3 && p3[o] == i + 1) {
									k++;
									p3qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 1 && o <= sum3 && p3[o] == kkk1) {
									k++;
									p3qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 1 && o <= sum3 && p3[o] == kkk2) {
									k++;
									p3qipai(o);
								}
							}
							jishu = i;
							huihe = 3;
							return;
						}
					}
					if (sum1 <= 6 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
						for (int i = 1; i <= 15; i++) {
							if (tot[i] == 4) {
								printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
								for (int j = 1; j <= sum3; j++) {
									while (j < sum3 && p3[j] == i)
										p3qipai(j);
								}
								paizu = 4;
								jishu = i;
								huihe = 3;
								return;
							}
						}
						if (tot[14] && tot[15]) {
							printf("XD\n");
							paizu = 5;
							sum3 -= 2;
							huihe = 3;
							return;
						}
						printf("不出\n");
						return;
					}
					printf("不出\n");
					return;
				} else if (fujia == 2) {
					int kkk1 = 0, kkk2 = 0;
					for (int j = 1; j <= 15; j++) {
						if (tot[j] == 2) {
							if (!kkk1) {
								kkk1 = j;
							} else {
								kkk2 = j;
							}
						}
						if (kkk1 && kkk2) {
							printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
							printf("%c%c%c%c\n", yingshei_c[kkk1], yingshei_c[kkk1], yingshei_c[kkk2], yingshei_c[kkk2]);
							int k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 3 && o <= sum3 && p3[o] == i) {
									k++;
									p3qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 3 && o <= sum3 && p3[o] == i + 1) {
									k++;
									p3qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 2 && o <= sum3 && p3[o] == kkk1) {
									k++;
									p3qipai(o);
								}
							}
							k = 0;
							for (int o = 1; o <= sum3; o++) {
								while (k < 2 && o <= sum3 && p3[o] == kkk2) {
									k++;
									p3qipai(o);
								}
							}
							jishu = i;
							huihe = 3;
							return;
						}
					}
					if (sum1 <= 6 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
						for (int i = 1; i <= 15; i++) {
							if (tot[i] == 4) {
								printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
								for (int j = 1; j <= sum3; j++) {
									while (j < sum3 && p3[j] == i)
										p3qipai(j);
								}
								paizu = 4;
								jishu = i;
								huihe = 3;
								return;
							}
						}
						if (tot[14] && tot[15]) {
							printf("XD\n");
							paizu = 5;
							huihe = 3;
							sum3 -= 2;
							return;
						}
						printf("不出\n");
						return;
					}
					printf("不出\n");
					return;
				} else {
					printf("%c%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
					int k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < 3 && j <= sum3 && p3[j] == i) {
							k++;
							p3qipai(j);
						}
					}
					k = 0;
					for (int j = 1; j <= sum3; j++) {
						while (k < 3 && j <= sum3 && p3[j] == i + 1) {
							k++;
							p3qipai(j);
						}
					}
					jishu = i;
					huihe = 3;
					return;
				}
				break;
			}
		}
		for (int i = 1; i <= 15; i++) {
			if (tot[i] == 4) {
				printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
				for (int j = 1; j <= sum3; j++) {
					while (j <= sum3 && p3[j] == i)
						p3qipai(j);
				}
				paizu = 4;
				huihe = 3;
				jishu = i;
				return;
			}
		}
		if (sum1 <= 6 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
			if (tot[14] && tot[15]) {
				printf("XD\n");
				sum3 -= 2;
				paizu = 5;
				huihe = 3;
				return;
			}
		}
	}
	printf("不出\n");
	return;
}
void p1qipai(int k) {			//p1弃第k张牌
	for (int i = k + 1; i <= sum1; i++) {
		p1[i - 1] = p1[i];
	}
	sum1--;
	return;
}
void p2qipai(int k) {			//p2弃第k张牌
	for (int i = k + 1; i <= sum2; i++) {
		p2[i - 1] = p2[i];
	}
	sum2--;
	return;
}
void p3qipai(int k) {			//p3弃第k张牌
	for (int i = k + 1; i <= sum3; i++) {
		p3[i - 1] = p3[i];
	}
	sum3--;
	return;
}

恶魔轮盘

C++
#include<windows.h>
#include<bits/stdc++.h>
using namespace std;
int Your = 6, Other = 6;
string daojuname[] = {"放大镜", "手铐", "小刀", "烟", "饮料"};
double Yourmoney;
 
int shi, kong;
int q[10], qlen; //1 实 2 空
int Rand(int x, int y) {
	int A = rand(), B = rand();
	return A * 1ll * B % (y - x + 1) + x;
}
int T;//ou->you
int daojulen;
int daoju[10];
int daojulen1;
int daoju1[10];
void build_gun() {
	kong = Rand(1, 4);
	shi = Rand(1, 4);
	qlen = 0;
	printf("%d发实弹,%d发空弹\n", shi, kong);
	int a1 = kong, a2 = shi;
	for (int i = 1; i <= kong + shi; i++) {
//      Sleep(50);
		int sum = Rand(1, a1 + a2);
		if (sum <= a1) {
			a1--;
			q[++qlen] = 2;
		} else {
			a2--;
			q[++qlen] = 1;
		}
	}
	int maxn = min(4, 8 - daojulen);
	printf("你获得了%d个道具:\n", maxn);
	daojulen += maxn;
	for (int i = 1; i <= maxn; i++) {
//      Sleep(50);
		int kkk = Rand(0, 4);
		daoju[kkk]++;
		cout << daojuname[kkk];
		if (i != maxn) {
			printf(",");
		}
	}
	printf("\n");
	maxn = min(4, 8 - daojulen1);
	printf("恶魔获得了%d个道具:\n", maxn);
	daojulen1 += maxn;
	for (int i = 1; i <= maxn; i++) {
		int kkk = Rand(0, 4);
		daoju1[kkk]++;
		cout << daojuname[kkk];
		if (i != maxn) {
			printf(",");
		}
	}
	printf("\n");
	system("pause");
	system("cls");
}
void IsOver() {
	if (Your <= 0) {
		printf("你输了\n");
		system("pause");
		exit(0);
	}
	if (Other <= 0) {
		printf("你赢了\n你获得了奖金$%.2lf\n", Yourmoney);
		system("pause");
		exit(0);
	}
}
void wait() {
	for (int i = 1; i <= 3; i++) {
		Sleep(500);
		printf(".");
	}
	Sleep(500);
}
int Hurt = 1;
int shoukao_you;
void Timeyou() {
	int x;
	while (1) {
		printf("你的生命:%d/6\n恶魔生命:%d/6\n", Your, Other);
		printf("剩余实弹数:%d    剩余空弹数:%d\n", shi, kong);
		printf("你现在拥有的道具:\n");
		for (int i = 0; i <= 4; i++) {
			cout << daojuname[i];
			printf("%d", daoju[i]);
			printf("个");
			if (i != 4) {
				printf(",");
			}
		}
		printf("\n");
		printf("恶魔现在拥有的道具:\n");
		for (int i = 0; i <= 4; i++) {
			cout << daojuname[i];
			printf("%d", daoju1[i]);
			printf("个");
			if (i != 4) {
				printf(",");
			}
		}
		printf("\n");
		printf("现在是你的回合\n");
		printf("你要\n1.向恶魔开枪\n2.向自己开枪\n");
		for (int i = 0; i <= 4; i++) {
			printf("%d.使用", i + 3);
			cout << daojuname[i] << '\n';
		}
		scanf("%d", &x);
		if (1 <= x && x <= 7) {
			break;
		}
		printf("输入不合法\n");
		Sleep(1145);
		system("cls");
	}
	if (x == 1) {
		printf("你决定向恶魔开枪");
		T++;
		wait();
		if (q[qlen] == 2) {
			Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(shi) * 1.0 / (double)(shi + kong)));
			kong--;
			qlen--;
			Hurt = 1;
			printf("是空弹\n");
			if (shoukao_you == 1) {
				shoukao_you = 0;
				printf("因为你使用了手铐,所以可以再来一次\n");
				Sleep(500);
				T--;
			}
		} else {
//          printf("((%lf))\n",Yourmoney);
			Yourmoney += (double)(5000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
//          printf("{{%lf}}\n",Yourmoney);
			shi--;
			qlen--;
			Other -= Hurt;
			Hurt = 1;
			printf("是实弹\n");
			Sleep(500);
			IsOver();
			if (shoukao_you == 1) {
				shoukao_you = 0;
				Yourmoney += 1000.0;
				printf("因为你使用了手铐,所以可以再来一次\n");
				Sleep(500);
				T--;
			}
		}
	} else if (x == 2) {
		printf("你决定向自己开枪");
		wait();
		if (q[qlen] == 2) {
			Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
			kong--;
			qlen--;
			Hurt = 1;
			printf("是空弹\n");
		} else {
			Yourmoney += 5000.0 * (1 + (double)(shi) * 1.0 / (double)(shi + kong));
			T++;
			shi--;
			qlen--;
			Your -= Hurt;
			Hurt = 1;
			printf("是实弹\n");
			Sleep(500);
			IsOver();
			if (shoukao_you == 1) {
				shoukao_you = 0;
				printf("因为你使用了手铐,所以可以再来一次\n");
				Sleep(500);
				T--;
			}
		}
	} else if (x == 3) { //{"放大镜","手铐","小刀","烟","饮料"};
		if (daoju[0]) {
			daoju[0]--;
			daojulen--;
			printf("你使用了放大镜\n");
			wait();
			printf("\n你看到了");
			if (q[qlen] == 1) {
				printf("实弹\n");
				Yourmoney += 2500.0;
			} else {
				printf("空弹\n");
			}
			Sleep(500);
			printf("\n");
		} else {
			printf("你现在没有放大镜\n");
			Sleep(1145);
			system("cls");
		}
	} else if (x == 4) {
		if (daoju[1]) {
			if (!shoukao_you) {
				daoju[1]--;
				daojulen--;
				printf("你使用了手铐\n");
				printf("你获得了连开两枪的机会\n");
				shoukao_you = 1;
			} else {
				printf("你已经用过手铐了\n");
			}
			Sleep(1145);
			system("cls");
		} else {
			printf("你现在没有手铐\n");
			Sleep(1145);
			system("cls");
		}
	} else if (x == 5) {
		if (daoju[2]) {
			if (Hurt == 1) {
				daoju[2]--;
				daojulen--;
				printf("你使用了小刀\n");
				printf("若下一发为实弹则伤害+1\n");
				Yourmoney += 500.0;
				Hurt = 2;
			} else {
				printf("你已经用过小刀了\n");
			}
			Sleep(1145);
			system("cls");
		} else {
			printf("你现在没有小刀\n");
			Sleep(1145);
			system("cls");
		}
	} else if (x == 6) {
		if (daoju[3]) {
			if (Your ^ 6) {
				daoju[3]--;
				daojulen--;
				printf("你使用了烟\n");
				printf("你回复了一点生命\n");
				Yourmoney += 500.0;
				Your++;
			} else {
				printf("你现在不需要烟\n");
			}
			Sleep(1145);
		} else {
			printf("你现在没有烟\n");
			Sleep(1145);
			system("cls");
		}
	} else {
		if (daoju[4]) {
			daoju[4]--;
			daojulen--;
			printf("你使用了饮料\n");
			wait();
			printf("\n");
			printf("你退了一发");
			if (q[qlen] == 2) {
				printf("空弹");
				kong--;
			} else {
				printf("实弹");
				Yourmoney += 500.0;
				shi--;
			}
			qlen--;
			Sleep(500);
		} else {
			printf("你现在没有饮料\n");
			Sleep(1145);
			system("cls");
		}
	}
	Sleep(1000);
	system("cls");
}
int Know;//通过放大镜得知下一发子弹
int shoukaoemo;
void fightyou() {
	printf("恶魔决定向你开枪");
	T++;
	wait();
	if (q[qlen] == 2) {
		Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
		kong--;
		qlen--;
		Hurt = 1;
		Know = 0;
		printf("是空弹\n");
		if (shoukaoemo) {
			printf("因为恶魔使用了手铐,所以可以再来一次\n");
			T--;
			Sleep(500);
			shoukaoemo = 0;
		}
	} else {
		Yourmoney += (double)(5000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
		shi--;
		qlen--;
		Your -= Hurt;
		Hurt = 1;
		printf("是实弹\n");
		Know = 0;
		Sleep(500);
		IsOver();
		if (shoukaoemo) {
			printf("因为恶魔使用了手铐,所以可以再来一次\n");
			Yourmoney += 1000.0;
			T--;
			Sleep(500);
			shoukaoemo = 0;
		}
	}
}
void fightemo() {
	printf("恶魔决定向自己开枪");
	wait();
	if (q[qlen] == 2) {
		Yourmoney += 2000.0 * (1 + (double)(shi) * 1.0 / (double)(shi + kong));
		kong--;
		qlen--;
		printf("是空弹\n");
		Know = 0;
	} else {
		Yourmoney += 5000.0 * (1 + (double)(kong) * 1.0 / (double)(shi + kong));
		shi--;
		T++;
		qlen--;
		Other -= Hurt;
		Hurt = 1;
		printf("是实弹\n");
		Know = 0;
		Sleep(500);
		IsOver();
		if (shoukaoemo) {
			printf("因为恶魔使用了手铐,所以可以再来一次\n");
			T--;
			Sleep(500);
			shoukaoemo = 0;
		}
	}
}
void Timeother() {
	printf("你的生命:%d/6\n恶魔生命:%d/6\n", Your, Other);
	printf("剩余实弹数:%d    剩余空弹数:%d\n", shi, kong);
	printf("你现在拥有的道具:\n");
	for (int i = 0; i <= 4; i++) {
		cout << daojuname[i];
		printf("%d", daoju[i]);
		printf("个");
		if (i != 4) {
			printf(",");
		}
	}
	printf("\n");
	printf("恶魔现在拥有的道具:\n");
	for (int i = 0; i <= 4; i++) {
		cout << daojuname[i];
		printf("%d", daoju1[i]);
		printf("个");
		if (i != 4) {
			printf(",");
		}
	}
	printf("\n");
	printf("现在是恶魔的回合\n");
	Sleep(1500);
 
	if (Other != 6) {
		if (daoju1[3]) {
			daoju1[3]--;
			daojulen1--;
			printf("恶魔使用了烟\n");
			printf("恶魔回复了一点生命\n");
			Other++;
			Yourmoney += 500.0;
			Sleep(1145);
			system("cls");
			return ;
		}
	}
	if (Know == 0 && kong == 0) {
		Know = 1;
	}
	if (Know == 0) {
		if (abs(shi - kong) < 2 && kong != 0) {
			if (daoju1[0]) {
				daoju1[0]--;
				daojulen1--;
				printf("恶魔使用了放大镜\n");
				wait();
				printf("\n恶魔看到了");
				if (q[qlen] == 1) {
					printf("实弹");
					Yourmoney += 2500.0;
					Know = 1;
				} else {
					printf("空弹");
					Know = 2;
				}
				Sleep(1145);
				system("cls");
				return ;
			}
		}
	} else if (Know == 1) {
		if (Hurt == 1 && daoju1[2]) {
			daoju1[2]--;
			daojulen1--;
			Hurt++;
			printf("恶魔使用了小刀\n");
			printf("若下一发为实弹则伤害+1");
			Yourmoney += 500.0;
			Sleep(1145);
			system("cls");
			return ;
		} else {
			if (shi >= kong + 1 && daoju1[1] && shoukaoemo != 1) {
				daoju1[1]--;
				daojulen1--;
				shoukaoemo = 1;
				printf("恶魔使用了手铐\n");
				printf("恶魔获得了连开两枪的机会\n");
				Sleep(1145);
				system("cls");
				return ;
			}
			fightyou();
			system("cls");
			return ;
		}
	} else {
		if (daoju1[4]) {
			daoju1[4]--;
			daojulen1--;
			printf("恶魔使用了饮料\n");
			wait();
			printf("\n");
			printf("恶魔退了一发");
			if (q[qlen] == 2) {
				printf("空弹");
				kong--;
			} else {
				printf("实弹");
				shi--;
			}
			Know = 0;
			qlen--;
			Sleep(500);
			Sleep(1145);
			system("cls");
			return ;
		} else {
			fightemo();
			Sleep(1145);
			system("cls");
			return ;
		}
	}
	if (shi >= kong) {
		fightyou();
	} else {
		fightemo();
	}
	Sleep(1145);
	system("cls");
}
void Play() {
	while (1) {
		if (shi == 0) {
			build_gun();
			T = 0;
			continue;
		}
		if (T % 2 == 0) {
			Timeyou();
		} else {
			Timeother();
		}
	}
}
void danrenplay() {
	for (int i = 1; i <= 3; i++) {
		printf(".");
//      Sleep(1000);
	}
	printf("\n");
	printf("又来了一位挑战者...\n");
	Sleep(1000);
	int x;
	while (1) {
		printf("准备好参与恶魔的游戏吗?胜者带走奖金,败者将会在此长眠\n1.好的\n2.没问题\n");
		scanf("%d", &x);
		if (x == 1 || x == 2) {
			break;
		}
		printf("输入不合法\n");
		Sleep(1145);
		system("cls");
	}
	while (1) {
		printf("你清楚我们的规则吗?\n1.清楚\n2.不清楚\n");
		scanf("%d", &x);
		if (x == 1 || x == 2) {
			break;
		}
		printf("输入不合法\n");
		Sleep(1145);
		system("cls");
	}
	if (x == 1) {
 
	} else {
		for (int i = 1; i <= 3; i++) {
			printf(".");
			Sleep(1000);
		}
		printf("\n");
		printf("规则:\n");
		printf("你和恶魔都各有6点生命\n") ;
		printf("每一回合开始前,你将知道一共有几发实弹,几发空弹,同时双方都将获得4个道具作为补给(上限为8个)\n");
		printf("每一回合,你可以选择对自己开枪,对恶魔开枪或者使用道具\n");
		printf("如果你对自己开枪,若为空弹,则可以继续行动,否则,停止行动\n");
		printf("如果你对恶魔开枪,无论如何,都将停止行动\n");
		printf("道具一览:\n");
		printf("放大镜:可以知道下一发子弹是空弹还是实弹\n");
		printf("手铐:增加一次本回合的行动次数\n");
		printf("小刀:若下一发子弹为实弹,则伤害+1\n");
		printf("烟:可以回复1点体力\n");
		printf("饮料:可以退一发子弹\n");
		system("pause");
		system("cls");
	}
 
	printf("好吧\n");
	Sleep(1145);
	printf("游戏将要开始了哦\n");
	Sleep(1145);
	system("cls");
	Play();
}
void IsOver_duo() {
	if (Your <= 0) {
		printf("玩家B赢了\n玩家B获得了奖金$%.2lf\n", Yourmoney);
		system("pause");
		exit(0);
	} else if (Other <= 0) {
		printf("玩家A赢了\n玩家A获得了奖金$%.2lf\n", Yourmoney);
		system("pause");
		exit(0);
	}
 
}
void build_gun_duo() {
	kong = Rand(1, 4);
	shi = Rand(1, 4);
	qlen = 0;
	printf("%d发实弹,%d发空弹\n", shi, kong);
	int a1 = kong, a2 = shi;
	for (int i = 1; i <= kong + shi; i++) {
//      Sleep(50);
		int sum = Rand(1, a1 + a2);
		if (sum <= a1) {
			a1--;
			q[++qlen] = 2;
		} else {
			a2--;
			q[++qlen] = 1;
		}
	}
	int maxn = min(2, 8 - daojulen);
	printf("玩家A获得了%d个道具:\n", maxn);
	daojulen += maxn;
	for (int i = 1; i <= maxn; i++) {
//      Sleep(50);
		int kkk = Rand(0, 4);
		daoju[kkk]++;
		cout << daojuname[kkk];
		if (i != maxn) {
			printf(",");
		}
	}
	printf("\n");
	maxn = min(2, 8 - daojulen1);
	printf("玩家B获得了%d个道具:\n", maxn);
	daojulen1 += maxn;
	for (int i = 1; i <= maxn; i++) {
		int kkk = Rand(0, 4);
		daoju1[kkk]++;
		cout << daojuname[kkk];
		if (i != maxn) {
			printf(",");
		}
	}
	printf("\n");
	system("pause");
	system("cls");
}
void Timeyou_duo() {
	int x;
	while (1) {
		printf("玩家A的生命:%d/4\n玩家B的生命:%d/4\n", Your, Other);
		printf("剩余实弹数:%d    剩余空弹数:%d\n", shi, kong);
		printf("玩家A现在拥有的道具:\n");
		for (int i = 0; i <= 4; i++) {
			cout << daojuname[i];
			printf("%d", daoju[i]);
			printf("个");
			if (i != 4) {
				printf(",");
			}
		}
		printf("\n");
		printf("玩家B现在拥有的道具:\n");
		for (int i = 0; i <= 4; i++) {
			cout << daojuname[i];
			printf("%d", daoju1[i]);
			printf("个");
			if (i != 4) {
				printf(",");
			}
		}
		printf("\n");
		printf("现在是玩家A的回合\n");
		printf("玩家A要\n1.向玩家B开枪\n2.向自己开枪\n");
		for (int i = 0; i <= 4; i++) {
			printf("%d.使用", i + 3);
			cout << daojuname[i] << '\n';
		}
		scanf("%d", &x);
		if (1 <= x && x <= 7) {
			break;
		}
		printf("输入不合法\n");
		Sleep(1145);
		system("cls");
	}
	if (x == 1) {
		printf("玩家A决定向玩家B开枪");
		T++;
		wait();
		if (q[qlen] == 2) {
			Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(shi) * 1.0 / (double)(shi + kong)));
			kong--;
			qlen--;
			Hurt = 1;
			printf("是空弹\n");
			if (shoukao_you == 1) {
				shoukao_you = 0;
				printf("因为玩家A使用了手铐,所以可以再来一次\n");
				Sleep(500);
				T--;
			}
		} else {
//          printf("((%lf))\n",Yourmoney);
			Yourmoney += (double)(5000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
//          printf("{{%lf}}\n",Yourmoney);
			shi--;
			qlen--;
			Other -= Hurt;
			Hurt = 1;
			printf("是实弹\n");
			Sleep(500);
			IsOver_duo();
			if (shoukao_you == 1) {
				shoukao_you = 0;
				Yourmoney += 1000.0;
				printf("因为玩家A使用了手铐,所以可以再来一次\n");
				Sleep(500);
				T--;
			}
		}
	} else if (x == 2) {
		printf("玩家A决定向自己开枪");
		wait();
		if (q[qlen] == 2) {
			Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
			kong--;
			qlen--;
			Hurt = 1;
			printf("是空弹\n");
		} else {
			Yourmoney += 5000.0 * (1 + (double)(shi) * 1.0 / (double)(shi + kong));
			T++;
			shi--;
			qlen--;
			Your -= Hurt;
			Hurt = 1;
			printf("是实弹\n");
			Sleep(500);
			IsOver_duo();
			if (shoukao_you == 1) {
				shoukao_you = 0;
				printf("因为玩家A使用了手铐,所以可以再来一次\n");
				Sleep(500);
				T--;
			}
		}
	} else if (x == 3) { //{"放大镜","手铐","小刀","烟","饮料"};
		if (daoju[0]) {
			daoju[0]--;
			daojulen--;
			printf("玩家A使用了放大镜\n");
			wait();
			printf("\n玩家A看到了");
			if (q[qlen] == 1) {
				printf("实弹\n");
				Yourmoney += 2500.0;
			} else {
				printf("空弹\n");
			}
			Sleep(500);
			printf("\n");
		} else {
			printf("玩家A现在没有放大镜\n");
			Sleep(1145);
			system("cls");
		}
	} else if (x == 4) {
		if (daoju[1]) {
			if (!shoukao_you) {
				daoju[1]--;
				daojulen--;
				printf("玩家A使用了手铐\n");
				printf("玩家A获得了连开两枪的机会\n");
				shoukao_you = 1;
			} else {
				printf("玩家A已经用过手铐了\n");
			}
			Sleep(1145);
			system("cls");
		} else {
			printf("玩家A现在没有手铐\n");
			Sleep(1145);
			system("cls");
		}
	} else if (x == 5) {
		if (daoju[2]) {
			if (Hurt == 1) {
				daoju[2]--;
				daojulen--;
				printf("玩家A使用了小刀\n");
				printf("若下一发为实弹则伤害+1\n");
				Yourmoney += 500.0;
				Hurt = 2;
			} else {
				printf("玩家A已经用过小刀了\n");
			}
			Sleep(1145);
			system("cls");
		} else {
			printf("玩家A现在没有小刀\n");
			Sleep(1145);
			system("cls");
		}
	} else if (x == 6) {
		if (daoju[3]) {
			if (Your ^ 4) {
				daoju[3]--;
				daojulen--;
				printf("玩家A使用了烟\n");
				printf("玩家A回复了一点生命\n");
				Yourmoney += 500.0;
				Your++;
			} else {
				printf("玩家A现在不需要烟\n");
			}
			Sleep(1145);
		} else {
			printf("玩家A现在没有烟\n");
			Sleep(1145);
			system("cls");
		}
	} else {
		if (daoju[4]) {
			daoju[4]--;
			daojulen--;
			printf("玩家A使用了饮料\n");
			wait();
			printf("\n");
			printf("玩家A退了一发");
			if (q[qlen] == 2) {
				printf("空弹");
				kong--;
			} else {
				printf("实弹");
				Yourmoney += 500.0;
				shi--;
			}
			qlen--;
			Sleep(500);
		} else {
			printf("玩家A现在没有饮料\n");
			Sleep(1145);
			system("cls");
		}
	}
	Sleep(1000);
	system("cls");
}
void Timeother_duo() {
	int x;
	while (1) {
		printf("玩家A的生命:%d/4\n玩家B的生命:%d/4\n", Your, Other);
		printf("剩余实弹数:%d    剩余空弹数:%d\n", shi, kong);
		printf("玩家A现在拥有的道具:\n");
		for (int i = 0; i <= 4; i++) {
			cout << daojuname[i];
			printf("%d", daoju[i]);
			printf("个");
			if (i != 4) {
				printf(",");
			}
		}
		printf("\n");
		printf("玩家B现在拥有的道具:\n");
		for (int i = 0; i <= 4; i++) {
			cout << daojuname[i];
			printf("%d", daoju1[i]);
			printf("个");
			if (i != 4) {
				printf(",");
			}
		}
		printf("\n");
		printf("现在是玩家B的回合\n");
		printf("玩家B要\n1.向玩家A开枪\n2.向自己开枪\n");
		for (int i = 0; i <= 4; i++) {
			printf("%d.使用", i + 3);
			cout << daojuname[i] << '\n';
		}
		scanf("%d", &x);
		if (1 <= x && x <= 7) {
			break;
		}
		printf("输入不合法\n");
		Sleep(1145);
		system("cls");
	}
	if (x == 1) {
		printf("玩家B决定向玩家A开枪");
		T++;
		wait();
		if (q[qlen] == 2) {
			Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(shi) * 1.0 / (double)(shi + kong)));
			kong--;
			qlen--;
			Hurt = 1;
			printf("是空弹\n");
			if (shoukaoemo == 1) {
				shoukaoemo = 0;
				printf("因为玩家B使用了手铐,所以可以再来一次\n");
				Sleep(500);
				T--;
			}
		} else {
//          printf("((%lf))\n",Yourmoney);
			Yourmoney += (double)(5000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
//          printf("{{%lf}}\n",Yourmoney);
			shi--;
			qlen--;
			Your -= Hurt;
			Hurt = 1;
			printf("是实弹\n");
			Sleep(500);
			IsOver_duo();
			if (shoukaoemo == 1) {
				shoukaoemo = 0;
				Yourmoney += 1000.0;
				printf("因为玩家B使用了手铐,所以可以再来一次\n");
				Sleep(500);
				T--;
			}
		}
	} else if (x == 2) {
		printf("玩家B决定向自己开枪");
		wait();
		if (q[qlen] == 2) {
			Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
			kong--;
			qlen--;
			Hurt = 1;
			printf("是空弹\n");
		} else {
			Yourmoney += 5000.0 * (1 + (double)(shi) * 1.0 / (double)(shi + kong));
			T++;
			shi--;
			qlen--;
			Other -= Hurt;
			Hurt = 1;
			printf("是实弹\n");
			Sleep(500);
			IsOver_duo();
			if (shoukao_you == 1) {
				shoukao_you = 0;
				printf("因为玩家B使用了手铐,所以可以再来一次\n");
				Sleep(500);
				T--;
			}
		}
	} else if (x == 3) { //{"放大镜","手铐","小刀","烟","饮料"};
		if (daoju1[0]) {
			daoju1[0]--;
			daojulen1--;
			printf("玩家B使用了放大镜\n");
			wait();
			printf("\n玩家B看到了");
			if (q[qlen] == 1) {
				printf("实弹\n");
				Yourmoney += 2500.0;
			} else {
				printf("空弹\n");
			}
			Sleep(500);
			printf("\n");
		} else {
			printf("玩家B现在没有放大镜\n");
			Sleep(1145);
			system("cls");
		}
	} else if (x == 4) {
		if (daoju1[1]) {
			if (!shoukaoemo) {
				daoju1[1]--;
				daojulen1--;
				printf("玩家B使用了手铐\n");
				printf("玩家B获得了连开两枪的机会\n");
				shoukaoemo = 1;
			} else {
				printf("玩家B已经用过手铐了\n");
			}
			Sleep(1145);
			system("cls");
		} else {
			printf("玩家B现在没有手铐\n");
			Sleep(1145);
			system("cls");
		}
	} else if (x == 5) {
		if (daoju1[2]) {
			if (Hurt == 1) {
				daoju1[2]--;
				daojulen1--;
				printf("玩家B使用了小刀\n");
				printf("若下一发为实弹则伤害+1\n");
				Yourmoney += 500.0;
				Hurt = 2;
			} else {
				printf("玩家B已经用过小刀了\n");
			}
			Sleep(1145);
			system("cls");
		} else {
			printf("玩家B现在没有小刀\n");
			Sleep(1145);
			system("cls");
		}
	} else if (x == 6) {
		if (daoju1[3]) {
			if (Other ^ 4) {
				daoju1[3]--;
				daojulen1--;
				printf("玩家B使用了烟\n");
				printf("玩家B回复了一点生命\n");
				Yourmoney += 500.0;
				Other++;
			} else {
				printf("玩家B现在不需要烟\n");
			}
			Sleep(1145);
		} else {
			printf("玩家B现在没有烟\n");
			Sleep(1145);
			system("cls");
		}
	} else {
		if (daoju1[4]) {
			daoju1[4]--;
			daojulen1--;
			printf("玩家B使用了饮料\n");
			wait();
			printf("\n");
			printf("玩家B退了一发");
			if (q[qlen] == 2) {
				printf("空弹");
				kong--;
			} else {
				printf("实弹");
				Yourmoney += 500.0;
				shi--;
			}
			qlen--;
			Sleep(500);
		} else {
			printf("玩家B现在没有饮料\n");
			Sleep(1145);
			system("cls");
		}
	}
	Sleep(1000);
	system("cls");
}
int asdasd;
void duorenplay() {
	while (1) {
		if (shi == 0) {
			build_gun_duo();
			T = asdasd;
			asdasd++;
			continue;
		}
		if (T % 2 == 0) {
			Timeyou_duo();
		} else {
			Timeother_duo();
		}
	}
}
int main() {
	srand(time(0));
	int x;
	while (1) {
		printf("请选择你想要的模式:\n1.单人\n2.双人(此模式中,生命值为4,道具补给为2)\n");
		scanf("%d", &x);
		if (x == 1 || x == 2) {
			break;
		}
		printf("输入不合法\n");
		Sleep(1145);
		system("cls");
	}
	system("cls");
	if (x == 1) {
		danrenplay();
	} else {
		Your = Other = 4;
		duorenplay();
	}
	return 0;
}

斗破苍穹

C++
#include<iostream>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<string>
using namespace std;
 
/*=============== all the structures ===============*/
 
typedef struct Frame
{
	COORD position[2];
	int flag;
}Frame;
 
 
/*=============== all the functions ===============*/
 
void SetPos(COORD a)// set cursor 
{
	HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(out, a);
}
 
void SetPos(int i, int j)// set cursor
{
	COORD pos={i, j};
	SetPos(pos);
}
 
void HideCursor()
{
	CONSOLE_CURSOR_INFO cursor_info = {1, 0}; 
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
 
//把第y行,[x1, x2) 之间的坐标填充为 ch
void drawRow(int y, int x1, int x2, char ch)
{
	SetPos(x1,y);
	for(int i = 0; i <= (x2-x1); i++)
		cout<<ch;
}
 
//在a, b 纵坐标相同的前提下,把坐标 [a, b] 之间填充为 ch
void drawRow(COORD a, COORD b, char ch)
{
	if(a.Y == b.Y)
		drawRow(a.Y, a.X, b.X, ch);
	else
	{
		SetPos(0, 25);
		cout<<"error code 01:无法填充行,因为两个坐标的纵坐标(x)不相等";
		system("pause");
	}
}
 
//把第x列,[y1, y2] 之间的坐标填充为 ch
void drawCol(int x, int y1, int y2, char ch)
{
	int y=y1;
	while(y!=y2+1)
	{
		SetPos(x, y);
		cout<<ch;
		y++;
	}
}
 
//在a, b 横坐标相同的前提下,把坐标 [a, b] 之间填充为 ch
void drawCol(COORD a, COORD b, char ch)
{
	if(a.X == b.X)
		drawCol(a.X, a.Y, b.Y, ch);
	else
	{
		SetPos(0, 25);
		cout<<"error code 02:无法填充列,因为两个坐标的横坐标(y)不相等";
		system("pause");
	}
}
 
//左上角坐标、右下角坐标、用row填充行、用col填充列
void drawFrame(COORD a, COORD  b, char row, char col)
{
	drawRow(a.Y, a.X+1, b.X-1, row);
	drawRow(b.Y, a.X+1, b.X-1, row);
	drawCol(a.X, a.Y+1, b.Y-1, col);
	drawCol(b.X, a.Y+1, b.Y-1, col);
}
 
void drawFrame(int x1, int y1, int x2, int y2, char row, char col)
{
	COORD a={x1, y1};
	COORD b={x2, y2};
	drawFrame(a, b, row, col);
}
 
void drawFrame(Frame frame, char row, char col)
{
	COORD a = frame.position[0];
	COORD b = frame.position[1];
	drawFrame(a, b, row, col);
}
 
void drawPlaying()
{
	drawFrame(0, 0, 48, 24, '=', '|');//    draw map frame;
	drawFrame(49, 0, 79, 4, '-', '|');//        draw output frame
	drawFrame(49, 4, 79, 9, '-', '|');//        draw score frame
	drawFrame(49, 9, 79, 20, '-', '|');//    draw operate frame
	drawFrame(49, 20, 79, 24, '-', '|');//    draw other message frame
	SetPos(52, 6);
	cout<<"得分:";
	SetPos(52, 7);
	cout<<"称号:";
	SetPos(52,10);
	cout<<"操作方式:";
	SetPos(52,12);
	cout<<"  a,s,d,w 控制战机移动。";
	SetPos(52,14);
	cout<<"  p 暂停游戏。";
	SetPos(52,16);
	cout<<"  e 退出游戏。";
}
 
//在[a, b)之间产生一个随机整数
int random(int a, int b)
{
	int c=(rand() % (a-b))+ a;
	return c;
}
 
//在两个坐标包括的矩形框内随机产生一个坐标
COORD random(COORD a, COORD b)
{
	int x=random(a.X, b.X);
	int y=random(a.Y, b.Y);
	COORD c={x, y};
	return c;
}
 
bool  judgeCoordInFrame(Frame frame, COORD spot)
{
	if(spot.X>=frame.position[0].X)
		if(spot.X<=frame.position[1].X)
			if(spot.Y>=frame.position[0].Y)
				if(spot.Y<=frame.position[0].Y)
					return true;
	return false;
}
 
void printCoord(COORD a)
{
	cout    <<"( "<<a.X<<" , "<<a.Y<<" )";
}
 
void printFrameCoord(Frame a)
{
	printCoord(a.position[0]);
	cout    <<" - ";
	printCoord(a.position[1]);
}
 
int drawMenu()
{
	SetPos(30, 1);
	cout<<"P l a n e  W a r";
	drawRow(3, 0, 79, '-');
	drawRow(5, 0, 79, '-');
	SetPos(28, 4);
	cout<<"w 和 s 选择, k 确定";
	SetPos(15, 11);
	cout<<"1. 简单的敌人";
	SetPos(15, 13);
	cout<<"2. 冷酷的敌人";
	drawRow(20, 0, 79, '-');
	drawRow(22, 0, 79, '-');
	SetPos(47, 11);
	cout<<"简单的敌人:";
	SetPos(51, 13);
	cout<<"简单敌人有着较慢的移动速度。";
	SetPos(24, 21);
	cout<<"制作:LJF神犇";
	int j=11;
	SetPos(12, j);
	cout<<">>";
	
	//drawFrame(45, 9, 79, 17, '=', '|');
	
	while(1)
	{    if( _kbhit() )
	{    
		char x=_getch();
		switch (x)
		{
		case 'w' :
			{    
				if( j == 13)
				{
					SetPos(12, j);
					cout<<" ";
					j = 11;
					SetPos(12, j);
					cout<<">>";
					SetPos(51, 13);
					cout<<"            ";
					SetPos(47, 11);
					cout<<"简单的敌人:";
					SetPos(51, 13);
					cout<<"简单敌人有着较慢的移动速度,容易对付。";
				}
				break;
			}
		case 's' :
			{    
				if( j == 11 )
				{
					SetPos(12, j);
					cout<<" ";        
					j = 13;
					SetPos(12, j);
					cout<<">>";
					SetPos(51, 13);
					cout<<"              ";
					SetPos(47, 11);
					cout<<"冷酷的敌人:";
					SetPos(51, 13);
					cout<<"冷酷的敌人移动速度较快,难对付哟!!!";
				}
				break;
			}
		case 'k' :
			{    
				if (j == 8)    return 1;
				else return 2;
			}
		}
	}
	}
}
 
/* 
DWORD WINAPI MusicFun(LPVOID lpParamte)
{
//DWORD OBJ;
sndPlaySound(TEXT("bgm.wav"), SND_FILENAME|SND_ASYNC);
return 0;
}
*/
 
 
/*================== the Game Class ==================*/
 
class Game
{
public:
	COORD position[10];
	COORD bullet[10];
	Frame enemy[8];
	int score;
	int rank;
	int rankf;
	string title;
	int flag_rank;
	
	Game ();
	
	//初始化所有
	void initPlane();
	void initBullet();
	void initEnemy();
	
	//初始化其中一个
	//void initThisBullet( COORD );
	//void initThisEnemy( Frame );
	
	void planeMove(char);
	void bulletMove();
	void enemyMove();
	
	//填充所有
	void drawPlane();
	void drawPlaneToNull();
	void drawBullet();
	void drawBulletToNull();
	void drawEnemy();
	void drawEnemyToNull();
	
	//填充其中一个
	void drawThisBulletToNull( COORD );
	void drawThisEnemyToNull( Frame );
	
	void Pause();
	void Playing();
	void judgePlane();
	void judgeEnemy();
	
	void Shoot();
	
	void GameOver();
	void printScore();
};
 
Game::Game()
{
	initPlane();
	initBullet();
	initEnemy();
	score = 0;
	rank = 25;
	rankf = 0;
	flag_rank = 0;
}
 
void Game::initPlane()
{
	COORD centren={39, 22};
	position[0].X=position[5].X=position[7].X=position[9].X=centren.X;
	position[1].X=centren.X-2;    
	position[2].X=position[6].X=centren.X-1;
	position[3].X=position[8].X=centren.X+1;
	position[4].X=centren.X+2;
	for(int i=0; i<=4; i++)
		position[i].Y=centren.Y;
	for(int i=6; i<=8; i++)
		position[i].Y=centren.Y+1;
	position[5].Y=centren.Y-1;
	position[9].Y=centren.Y-2;
}
 
void Game::drawPlane()
{
	for(int i=0; i<9; i++)
	{
		SetPos(position[i]);
		if(i!=5)
			cout<<"O";
		else if(i==5)
			cout<<"|";        
	}
}
 
void Game::drawPlaneToNull()
{
	for(int i=0; i<9; i++)
	{
		SetPos(position[i]);
		cout<<" ";
	}    
}
 
void Game::initBullet()
{
	for(int i=0; i<10; i++)
		bullet[i].Y = 30;
}
 
void Game::drawBullet()
{
	for(int i=0; i<10; i++)
	{
		if( bullet[i].Y != 30)
		{
			SetPos(bullet[i]);
			cout<<"^";    
		}
	}
}
 
void Game::drawBulletToNull()
{
	for(int i=0; i<10; i++)
		if( bullet[i].Y != 30 )
		{
			COORD pos={bullet[i].X, bullet[i].Y+1};
			SetPos(pos);
			cout<<" ";
		}    
}
 
void Game::initEnemy()
{
	COORD a={1, 1};
	COORD b={45, 15};
	for(int i=0; i<8; i++)
	{
		enemy[i].position[0] = random(a, b);
		enemy[i].position[1].X = enemy[i].position[0].X + 3;
		enemy[i].position[1].Y = enemy[i].position[0].Y + 2;
	}
}
 
void Game::drawEnemy()
{
	for(int i=0; i<8; i++)
		drawFrame(enemy[i].position[0], enemy[i].position[1], '-', '|');
}
 
void Game::drawEnemyToNull()
{
	for(int i=0; i<8; i++)
	{
		drawFrame(enemy[i].position[0], enemy[i].position[1], ' ', ' ');
	}        
}
 
void Game::Pause()
{
	SetPos(61,2);
	cout<<"               ";
	SetPos(61,2);
	cout<<"暂停中...";
	char c=_getch();
	while(c!='p')
		c=_getch();
	SetPos(61,2);
	cout<<"         ";
}
 
void Game::planeMove(char x)
{
	if(x == 'a')
		if(position[1].X != 1)
			for(int i=0; i<=9; i++)
				position[i].X -= 2;
	
	if(x == 's')
		if(position[7].Y != 23)
			for(int i=0; i<=9; i++)
				position[i].Y += 1;
	
	if(x == 'd')
		if(position[4].X != 47)
			for(int i=0; i<=9; i++)
				position[i].X += 2;
	
	if(x == 'w')
		if(position[5].Y != 3)
			for(int i=0; i<=9; i++)
				position[i].Y -= 1;
}
 
void Game::bulletMove()
{
	for(int i=0; i<10; i++)
	{
		if( bullet[i].Y != 30)
		{
			bullet[i].Y -= 1;
			if( bullet[i].Y == 1 )
			{
				COORD pos={bullet[i].X, bullet[i].Y+1};
				drawThisBulletToNull( pos );
				bullet[i].Y=30;
			}
			
		}
	}
}
 
void Game::enemyMove()
{
	for(int i=0; i<8; i++)
	{
		for(int j=0; j<2; j++)
			enemy[i].position[j].Y++;
		
		if(24 == enemy[i].position[1].Y)
		{
			COORD a={1, 1};
			COORD b={45, 3};
			enemy[i].position[0] = random(a, b);
			enemy[i].position[1].X = enemy[i].position[0].X + 3;
			enemy[i].position[1].Y = enemy[i].position[0].Y + 2;
		}
	}
}
 
void Game::judgePlane()
{
	for(int i = 0; i < 8; i++)
		for(int j=0; j<9; j++)
			if(judgeCoordInFrame(enemy[i], position[j]))
			{
				SetPos(62, 1);
				cout<<"坠毁";
				drawFrame(enemy[i], '+', '+');
				Sleep(1000);
				GameOver();
				break;
			}
}
 
void Game::drawThisBulletToNull( COORD c)
{
	SetPos(c);
	cout<<" ";
}
 
void Game::drawThisEnemyToNull( Frame f )
{
	drawFrame(f, ' ', ' ');
}
 
void Game::judgeEnemy()
{
	for(int i = 0; i < 8; i++)
		for(int j = 0; j < 10; j++)
			if( judgeCoordInFrame(enemy[i], bullet[j]) )
			{
				score += 5;
				drawThisEnemyToNull( enemy[i] );
				COORD a={1, 1};
				COORD b={45, 3};
				enemy[i].position[0] = random(a, b);
				enemy[i].position[1].X = enemy[i].position[0].X + 3;
				enemy[i].position[1].Y = enemy[i].position[0].Y + 2;                    
				drawThisBulletToNull( bullet[j] );
				bullet[j].Y = 30;
			}
}
 
void Game::Shoot()
{
	for(int i=0; i<10; i++)
		if(bullet[i].Y == 30)
		{
			bullet[i].X = position[5].X;
			bullet[i].Y = position[5].Y-1;
			break;
		}
}
 
void Game::printScore()
{
	if(score == 120 && flag_rank == 0)
	{
		rank -= 3;
		flag_rank = 1;
	}
	
	else if( score == 360 && flag_rank == 1)
	{
		rank -= 5;
		flag_rank = 2;
	}
	else if( score == 480 && flag_rank == 2)
	{
		rank -= 5;
		flag_rank = 3;
	}
	int x=rank/5;
	SetPos(60, 6);
	cout<<score;
	
	if( rank!=rankf )
	{
		SetPos(60, 7);
		if( x == 5)
			title="初级飞行员";
		else if( x == 4)
			title="中级飞行员";
		else if( x == 3)
			title="高级飞行员";
		else if( x == 2 )
			title="王牌飞行员";
		cout<<title;
	}
	rankf = rank;
}
 
void Game::Playing()
{
	//HANDLE MFUN;
	//MFUN= CreateThread(NULL, 0, MusicFun, NULL, 0, NULL); 
	
	drawEnemy();
	drawPlane();
	
	int flag_bullet = 0;
	int flag_enemy = 0;
	
	while(1)
	{
		Sleep(8);
		if(_kbhit())
		{
			char x = _getch();
			if ('a' == x || 's' == x || 'd' == x || 'w' == x)
			{
				drawPlaneToNull();
				planeMove(x);
				drawPlane();
				judgePlane();
			}            
			else if ('p' == x)
				Pause();
			else if( 'k' == x)
				Shoot();
			else if( 'e' == x)
			{
				//CloseHandle(MFUN);
				GameOver();
				break;
			}
			
		}
		/* 处理子弹 */
		if( 0 == flag_bullet )
		{
			bulletMove();
			drawBulletToNull();
			drawBullet();
			judgeEnemy();
		}            
		flag_bullet++;
		if( 5 == flag_bullet )
			flag_bullet = 0;
		
		/* 处理敌人 */
		if( 0 == flag_enemy )
		{
			drawEnemyToNull();
			enemyMove();            
			drawEnemy();
			judgePlane();
		}
		flag_enemy++;
		if( flag_enemy >= rank )
			flag_enemy = 0;
		
		/* 输出得分 */
		printScore();
	}
}
 
void Game::GameOver()
{
	system("cls");                
	COORD p1={28,9};
	COORD p2={53,15};
	drawFrame(p1, p2, '=', '|');
	SetPos(36,12);
	string str="Game Over!";
	for(int i=0; i<str.size(); i++)
	{
		Sleep(80);
		cout<<str[i];
	}
	Sleep(1000);
	system("cls");
	drawFrame(p1, p2, '=', '|');
	SetPos(31, 11);
	cout<<"击落敌机:"<<score/5<<" 架";
	SetPos(31, 12);
	cout<<"得  分:"<<score;
	SetPos(31, 13);
	cout<<"获得称号:"<<title;
	SetPos(30, 16);
	Sleep(1000);
	cout<<"继续? 是(y)| 否(n)制作:最牛的LJF";
	as:
	char x=_getch();
	if (x == 'n')
		exit(0);
	else if (x == 'y')
	{
		system("cls");
		Game game;
		int a = drawMenu();
		if(a == 2)
			game.rank = 20;
		system("cls");
		drawPlaying();
		game.Playing();
	}
	else goto as;
}
 
/*================== the main function ==================*/
int main()
{
	//游戏准备
	srand((int)time(0));    //随机种子
	HideCursor();    //隐藏光标
	
	Game game;
	int a = drawMenu();
	if(a == 2)
		game.rank = 20;
	system("cls");
	drawPlaying();
	game.Playing();
}

狼人杀

C++
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
const int daytime=0,night=1;
int day=0, during_time=daytime, player_number, my_number;
HWND hwnd=GetForegroundWindow();
const int blue=0,yellow=1,red=2,green=3,purple=4,white=5;//颜色常量 
void color(int c){
	switch(c){
		case red:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);break;
		case green:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);break;
		case yellow:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);break;
		case blue:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);break;
		case white:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN | FOREGROUND_BLUE);break;
		case purple:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);break;
	}
}
int idx_police=-1;
void gotoxy(int x,int y){
	COORD position;
	position.X=x;
	position.Y=y;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), position);
}
void init_Show_Window(){
	system("mode con lines=60 cols=188"); 
	ShowWindow(hwnd,SW_MAXIMIZE);//窗口最大化 
	DeleteMenu(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE, MF_BYCOMMAND);
	DrawMenuBar(GetConsoleWindow());//删除×字符 
}
 
/*玩家类*/
const int nvwu=0,cunmin=1,yuyanjia=2,langren=3,lieren=4,shouwei=5,good=6,die=1,life=2;
class player{
public:
	int type;
	int die_or_life;
	int how(){
		return die_or_life;
	}
	int is_light;//是否已经公布 
	int killer;
};
player players[1000];
 
/*转换白天模式*/ 
void change_daytime(){
	during_time=daytime;
	day++;
}
 
/*转换黑夜模式*/
void change_night(){
	during_time=night;
}
int nnvwu=0,ncunmin=0,nyuyanjia=0,nlangren=0,nlieren=0,nshouwei=0;
int idxnvwu,idxshouwei,idxyuyanjia,idxlieren,idxlangren[4]={-1,-1,-1,-1};
 
/*b是否在Arr中*/
bool is_include(int arr[],int b,int l){
	for(int i=0;i<l;i++){
		if(arr[i]==b)
			return true;
	}
	return false;
}
 
/*初始化人数*/
void init_players(){
	my_number=rand()%player_number;
	if(player_number==12) nlangren=4;
	else if(player_number>=10) nlangren=3;
	else nlangren=2;
	for(int i=0;i<player_number;i++)
	{
		players[i].die_or_life=life;
		players[i].is_light=0;
		players[i].type=-1;
		players[i].killer=2147483647;
	}
	for(int i=0;i<nlangren;i++)
	{
		int p=rand()%player_number;
		if(!is_include(idxlangren,p,4))
			idxlangren[i]=p,players[p].type=langren;
		else
			i--;
		Sleep(rand()%80+100);
	}
	if(player_number==12)
	{
		do{
			idxshouwei=rand()%player_number;
		}while(players[idxshouwei].type!=-1);   
		players[idxshouwei].type=shouwei;   
	}
	do{
		idxnvwu=rand()%player_number;
	}while(players[idxnvwu].type!=-1);
	players[idxnvwu].type=nvwu;
	if(player_number>=10)
	{
		do{
			idxlieren=rand()%player_number;
		}while(players[idxlieren].type!=-1);
		players[idxlieren].type=lieren;   
	}
	do{
		idxyuyanjia=rand()%player_number;
	}while(players[idxyuyanjia].type!=-1);
	players[idxyuyanjia].type=yuyanjia;
	for(int i=0;i<player_number;i++)
		if(players[i].type==-1)
			players[i].type=cunmin,
			ncunmin++;
	if(players[my_number].type==langren)
	{
		for(int i=0;i<nlangren;i++)
		{
			players[idxlangren[i]].is_light=1;
		}
	}
	players[my_number].is_light=1;
}
 
/*在屏幕上打印东西*/
void print(){
	gotoxy(0,0);
	cout<<"作者:洛谷393864";
	gotoxy(90,0);
	if(during_time==night)
		color(red);
	else
		color(blue);
	printf("第%d天 | ",day);
	if(during_time==night) cout<<"黑夜";
	else cout<<"白天";
	
	gotoxy(0,3);
	color(blue);
	cout<<" 我的号位:"<<my_number+1;
	for(int i=0;i<player_number;i++){
		gotoxy(i*8+1,4);
		if(i==idx_police) color(yellow);
		else color(blue);
		cout<<i+1<<"号位"; 
		gotoxy(i*8+1,5);
		if(players[i].how()==die){
			color(red);
			cout<<"死 亡";
		}else{
			color(green);
			cout<<"存 活";
		}
		gotoxy(i*8+1,6);
		color(blue);
		if(players[i].is_light){
			if(players[i].is_light==1){
				switch(players[i].type){
					case nvwu: cout<<"女 巫";break;
					case yuyanjia: cout<<"\b预言家";break;
					case cunmin: cout<<"村 民";break;
					case langren:cout<<"狼 人"; break;
					case lieren:cout<<"猎 人"; break; 
					case shouwei:cout<<"守 卫"; break;
				}   
			}else{
				cout<<"好人";
			}
			
		}else{
			cout<<"未知";
		}
	}
	
} 
 
/*判断是否结束,没结束返回0  好人胜利返回1  狼人胜利返回2   平局返回3*/
int is_end(){
	int die_bad=0;
	int die_people=0;
	int die_god=0;
	for(int i=0;i<player_number;i++){
		if((players[i].type == nvwu || players[i].type == yuyanjia || players[i].type == shouwei)&&players[i].die_or_life==die)
			die_god++;
		else if(players[i].type == langren && players[i].die_or_life==die)
			die_bad++;
		else if(players[i].type == cunmin && players[i].die_or_life==die)
			die_people++;
	}
	if((die_bad==die_people || die_bad==die_god)&&(die_bad>=nlangren))
		return 3;
	if(die_bad>=nlangren)
		return 1;
	if(die_people>=ncunmin||die_god>=(player_number>=10 ? 3:2))
		return 2;
	return 0;
}
 
/*游戏开始前的骚操作*/
void before_game(){
	srand(time(NULL));
	init_Show_Window();
	color(green);
	cout<<"欢迎来到狼人杀游戏\t\t\t为了更好的游戏体验,请右键点击上方↑↑,点击\"属性\",点击\"字体\"栏目,将字体修改为宋体或新宋体,将字号改为20\n作者:洛谷393864\n请勿私自转载,违者依法追究法律责任  注:10 11 12人局开设猎人  12人局开设守卫警长\n______________________\n";
	cout<<"请输入玩家人数(8-12人):";
	cin>>player_number;
	while(player_number<8||player_number>12)
	{ cout<<"请重新输入!\n"; cin>>player_number; }
	system("cls");
	cout<<"初始化身份中,请稍等.";
	for(int i=0;i<6;i++){
		for(int j=0;j<12;j++){
			cout<<".";
			Sleep(50);
		}   
		cout<<"\b\b\b\b\b\b\b\b\b\b\b\b            \b\b\b\b\b\b\b\b\b\b\b\b";
	}
	system("cls");
	
	init_players();
	cout<<"我的号位:"<<my_number+1<<endl
	<<"我的身份:";
	switch(players[my_number].type){
		case nvwu: cout<<"女巫\n";break;
		case yuyanjia: cout<<"预言家\n";break;
		case cunmin: cout<<"村民\n";break;
		case langren:cout<<"狼人\n";break;  
		case lieren:cout<<"猎人\n"; break;  
		case shouwei:cout<<"守卫\n";break;
	}
	change_daytime();
	system("pause");
	system("cls");
	cout<<"游戏加载中.";int ppppp=rand()%3+2;
	for(int i=0;i<ppppp;i++){
		for(int j=0;j<6;j++){
			cout<<".";
			Sleep(rand()%100+150);
		}   
		cout<<"\b\b\b\b\b\b      \b\b\b\b\b\b";
	}   
	print();
} 
 
/*每一天开始前的操作*/
void something_before_everyday(){
	change_night();
	system("cls");
	print();
	gotoxy(0,7);
	cout<<"________________________";
	gotoxy(0,8);
	color(white);
	cout<<"天黑~请闭眼~~~\n";
}
 
/*守卫操作*/
int shouweishou=0;
int ShouWei(){
	color(blue);
	cout<<"守卫~请睁眼~~\n";
	Sleep(1500);
	cout<<"你要守护的是?\n";
	if(players[my_number].type==shouwei&&players[my_number].die_or_life == life){
		cin>>shouweishou;
		while(!(shouweishou>=1&&shouweishou<=player_number&&players[shouweishou-1].die_or_life == life)){
			cout<<"请重新输入!\n";
			cin>>shouweishou;
		}
		cout<<"你今晚要守护的是"<<shouweishou<<"号\n";
		Sleep(1500); 
		shouweishou--;
	}else{
		if(players[idxshouwei].die_or_life == life){
			shouweishou=rand()%10;
			while(!(shouweishou>=1&&shouweishou<=player_number&&players[shouweishou-1].die_or_life == life)){
				shouweishou=rand()%10;
			}
		}
	}   
	Sleep(2000);
	cout<<"守卫请闭眼"<<endl<<endl;
	return shouweishou;
} 
 
/*狼人操作*/
int LangRen(){
	int langrensha=-1;
	color(red);
	cout<<"狼人~请睁眼~~~\n";
	Sleep(1500);
	cout<<"你们今晚要杀~谁~~??\n";
	if(players[my_number].type==langren&&players[my_number].die_or_life == life){
		cin>>langrensha;
		while(!(langrensha>=1&&langrensha<=player_number&&players[langrensha-1].die_or_life==life)){
			cout<<"请重新输入!\n";
			cin>>langrensha;
		}
		cout<<"你们今晚要杀的是"<<langrensha--<<"号\n";
		Sleep(3500);
	}else{
		while(langrensha==-1 || players[langrensha].die_or_life == die || players[langrensha].type==langren){
			langrensha=rand()%player_number;
		}
		Sleep(3000);
	}
	cout<<"狼人请~闭眼~~\n\n";
	return langrensha;
}
 
/*女巫操作*/
int nvwujiu=0,nvwudu=0,is_nvwujiu=0,is_nvwudu=0;
int NvWu(int langrensha){
	color(purple);
	cout<<"女巫~~请睁眼~~\n";
	Sleep(2000);
	if(players[my_number].type==nvwu&&players[my_number].die_or_life == life){
		if(is_nvwujiu) 
			cout<<"你已经用过解药\n",Sleep(1500);
		else
		{
			cout<<"今晚"<<langrensha+1<<"号死了,你想用解药吗?(1想 / 2不想)\n";
			int is_nvwujie=0;
			cin>>is_nvwujie;
			while(is_nvwujie!=1&&is_nvwujie!=2){
				cout<<"请重新输入\n";
				cin>>is_nvwujie;
			} 
			if(is_nvwujie==1) {
				Sleep(1000);
				cout<<"已经解救"<<langrensha+1<<"号\n";
				nvwujiu=langrensha;
			}
			is_nvwujiu=1;
		}
		Sleep(1500);
		if(::is_nvwudu) cout<<"你已经用过解药\n",Sleep(1500);
		else
		{
			cout<<"你想用毒药吗?(1想 / 2不想)\n";
			Sleep(1500);
			int is_nvwudu=0;
			cin>>is_nvwudu;
			while(is_nvwudu!=1&&is_nvwudu!=2){
				cout<<"请重新输入\n";
				cin>>is_nvwudu;
			}   
			if(is_nvwudu==1){
				Sleep(1500);
				cout<<"你想毒谁?\n"; 
				cin>>nvwudu;
				while(!(nvwudu>=1&&nvwudu<=player_number&&players[nvwudu].die_or_life==life)){
					cout<<"请重新输入\n";
					cin>>nvwudu; 
				}
				nvwudu--;
				Sleep(1500);
				cout<<"已经毒死了"<<nvwudu+1<<"号\n";
			}
			::is_nvwudu=1;
		}   
	}else{
		if(players[idxnvwu].die_or_life == life){
			if(!is_nvwujiu)
			{
				int is_jiu=rand()%8;
				if(is_jiu==0){
					nvwujiu=langrensha;
					is_nvwujiu=1;
				}   
			}
			if(!is_nvwudu)
			{
				int is_du=rand()%4;
				if(is_du==0){
					int num=rand()%player_number;
					nvwudu=num;
					is_nvwudu=1;
				}
			}
		}
		
	} 
	cout<<"女巫~请闭眼~~\n\n";
	return nvwujiu*10000+nvwudu;//传回两个变量,“加密”操作 
}
 
int yuyanjiabixutoupiao=-1;
/*预言家操作*/
void YuYanJia(){
	color(green);
	cout<<"预言家~请睁眼~~\n";
	Sleep(2000);
	if(players[my_number].type==yuyanjia&&players[my_number].die_or_life == life){
		cout<<"请问你想查验谁的身份\n";
		int p;
		cin>>p;
		while(!(p>=1&&p<=player_number)){
			cout<<"请重新输入!\n";
			cin>>p;
		}
		Sleep(2000);
		cout<<p<<"号的身份是——";
		Sleep(1000);
		if(players[p-1].type == langren){
			cout<<"狼人\n";
			players[p-1].is_light = 1;
		}else{
			cout<<"好人\n";
			players[p-1].is_light = 2;
		}
	}else{
		int p=-1;
		while(p==-1||players[p].die_or_life==die||p==idxlieren)
			p=rand()%player_number;
		if(players[p].type==langren)//锁定目标! 
		{
			yuyanjiabixutoupiao=p;
		}
	}
	cout<<"预言家~~请闭眼~~\n";
}
 
/*黑夜操作*/
int LANGRENSHA=-1,NVWUDU=-1,NVWUJIU=-1,SHOUWEISHOU=-1; 
void Night(){   
	LANGRENSHA=-1,NVWUDU=-1,NVWUJIU=-1,SHOUWEISHOU=-1; 
	
	//如果有12人局,添加守卫 
	if(player_number==12){
		SHOUWEISHOU=ShouWei();
		Sleep(2000);
	} 
	/*狼人部分*/
	LANGRENSHA=LangRen();
	Sleep(3500);
	/*女巫部分*/ 
	int nvwu=NvWu(LANGRENSHA);
	NVWUDU=nvwu%10+nvwu/10%10;
	NVWUJIU=nvwu/10000%10+nvwu/100000%10;
	Sleep(3000);
	/*预言家部分*/
	YuYanJia();
	Sleep(2000);
}
 
/*猎人操作*/
void Lieren(){
	int lierendai=-1;
	cout<<idxlieren+1<<"号是猎人\n";
	
	players[idxlieren].is_light = 1;
	Sleep(1000);
	if(idxlieren==my_number){
		cout<<"你想带走几号?\n";
		cin>>lierendai;
		while(lierendai<1||lierendai>player_number||players[lierendai].die_or_life==die){
			cout<<"请重新输入!\n";
			cin>>lierendai;
		}
		lierendai--;
	}else{
		lierendai=rand()%player_number;
		while(players[lierendai].die_or_life == die){
			lierendai=rand()%player_number;
		}
	}
	Sleep(2000);
	cout<<"猎人选择带走"<<lierendai+1<<"号\n";
	Sleep(2000);
	players[lierendai].die_or_life = die;
}
 
void police_die();
/*判断谁死了*/
void panduansiwang(){
	system("cls");
	print(); 
	gotoxy(0,7);
	cout<<"________________________\n";
	Sleep(3000);
	color(white);
	cout<<"天亮了\n";
	Sleep(2000);
	gotoxy(0,9);
	cout<<"昨晚";
	bool is_die[15]={false},is_die_lieren=false,flag=false;
	for(int i=0;i<player_number;i++)
	{
		if(players[i].die_or_life==life)
		{
			if(i==LANGRENSHA||i==NVWUDU) {
				if(players[i].type==lieren) is_die_lieren=true;
				players[i].killer= (i==LANGRENSHA ? langren:nvwu);
				players[i].die_or_life=die;
				is_die[i]=true;
			}
			if(i==SHOUWEISHOU||i==NVWUJIU) {
				if(players[i].type==lieren) is_die_lieren=false;
				players[i].killer=-1;
				players[i].die_or_life=life;
				is_die[i]=false;
			}   
		}
	}
	bool is_police_die=false;
	for(int i=0;i<player_number;i++)
	{
		if(is_die[i])
		{
			if(flag) cout<<"和"<<i+1<<"号";
			else cout<<i+1<<"号",flag=true;
			if(i==idx_police) 
				is_police_die=true;
		}
	}
	if(flag) cout<<"死了\n";
	else cout<<"是平安夜\n";
	
	if(is_die_lieren) Lieren();
	if(is_police_die) police_die();
}
 
/*选警长*/
void choose_police(){
	system("cls");
	print();
	color(blue);
	gotoxy(0,7);
	cout<<"________________________\n";
	color(yellow);
	cout<<"下面开始选举警长,各位不能选举自己~\n";
	int tong[100]={0},cannot[100],must[100]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
	memset(cannot,-1,sizeof(cannot));
	CHOOSE:
	color(yellow);
	Sleep(1500);
	for(int i=0;i<player_number;i++)
	{
		if(players[i].die_or_life==life&&!is_include(cannot,i,player_number))
		{
			if(i==my_number)
			{
				cout<<"你要选举几号?\n";
				int n;
				cin>>n;
				while(n<1||n>player_number||n==i+1||players[n-1].die_or_life==die||!is_include(must,n-1,player_number))
				{
					cout<<"请重新输入!\n";
					cin>>n;
				}
				cout<<i+1<<"号选举"<<n--<<"号\n";
				tong[n]++;
			}
			else
			{
				int n=rand()%player_number;
				while(n==i||players[n].die_or_life==die||!is_include(must,n,player_number))
					n=rand()%player_number;
				cout<<i+1<<"号选举"<<n+1<<"号\n";
				tong[n]++;
			}
			Sleep(1500);
		}
	}
	int idx_max=-1,maxn=-1,len=0;
	for(int i=0;i<player_number;i++)
		if(maxn<tong[i])
		{
			maxn=tong[i];
			idx_max=i;
		}
	int maxn_arr[15]={0};
	for(int i=0;i<player_number;i++)
	{
		if(tong[i]==maxn)
		{
			maxn_arr[len++]=i;
		}
	}
	color(blue);
	if(len>1)
	{
		for(int i=0;i<len;i++)
		{
			if(i==len-1)
			{
				cout<<maxn_arr[i]+1<<"号平票\n"; 
			}
			else
			{
				cout<<maxn_arr[i]+1<<"号,";
			}
		}
		for(int i=0;i<len;i++)
			cannot[i]=maxn_arr[i];
		for(int i=0;i<player_number;i++)
		{
			if(is_include(cannot,i,len))
				must[i]=i;
			else
				must[i]=-1;
		}
		color(white);
		goto CHOOSE;
	}
	cout<<"恭喜"<<idx_max+1<<"号当选警长\n";
	Sleep(3000);
	idx_police=idx_max;
	return;
}
 
/*投票*/
int toupiao(){
	int tong[100]={0},cannot[100]={},must[100]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; 
	memset(cannot,-1,sizeof(cannot));
	gotoxy(0,7);
	color(blue);
	cout<<"________________________\n";
	color(white);
	cout<<"下面进入投票环节\n";
	memset(tong,0,sizeof(tong));
	Sleep(2000);
	TOUPIAO:
	for(int i=0;i<player_number;i++){
		if(players[i].die_or_life == life&&!is_include(cannot,i,player_number)){
			if(i==my_number){
				color(white);
				cout<<"你要投几号?\n";
				int n;
				cin>>n;
				while(!(n>=1&&n<=player_number&&is_include(must,n-1,player_number))){
					cout<<"请重新输入!\n";
					cin>>n;
				}
				Sleep(2000);
				cout<<setw(2)<<my_number+1<<"号投了"<<setw(2)<<n<<"号";
				if(my_number==n-1) color(red),cout<<"快来看!这有个疯子投自己!"; 
				if(i==idx_police) color(yellow),cout<<"(警长)\n"; else cout<<"\n";
				if(i==idx_police) tong[n-1]++;
				tong[n-1]++;
			}else{
				color(white);
				int t=-1;
				while(t==-1 || players[t].die_or_life == die || t==i || !is_include(must,t,player_number)){
					if(i==idxyuyanjia&&yuyanjiabixutoupiao!=-1)
					{
						t=yuyanjiabixutoupiao;
						yuyanjiabixutoupiao=-1;
						continue;
					}
					t=rand()%player_number;
					if(is_include(idxlangren,i,nlangren))
					{
						if(players[t].type == langren)
							t=-1;
					}
				}
				cout<<setw(2)<<i+1<<"号"<<"投了"<<setw(2)<<t+1<<"号";
				if(i==idx_police) cout<<"(警长2票)\n"; else cout<<"\n";
				if(i==idx_police) tong[t]++;
				tong[t]++;  
			}
			
			Sleep(rand()%1000+1000);
		}
	}
	int idx_max=-1,maxn=-1,len=0;
	for(int i=0;i<player_number;i++)
		if(maxn<tong[i])
		{
			maxn=tong[i];
			idx_max=i;
		}
	int maxn_arr[15]={0};
	for(int i=0;i<player_number;i++)
	{
		if(tong[i]==maxn)
		{
			maxn_arr[len++]=i;
		}
	}
	color(blue);
	if(len>1)
	{
		for(int i=0;i<len;i++)
		{
			if(i==len-1)
			{
				cout<<maxn_arr[i]+1<<"号平票\n"; 
			}
			else
			{
				cout<<maxn_arr[i]+1<<"号,";
			}
		}
		for(int i=0;i<len;i++)
			cannot[i]=maxn_arr[i];
		for(int i=0;i<player_number;i++)
		{
			if(is_include(cannot,i,len))
				must[i]=i;
			else
				must[i]=-1;
		}
		color(white);
		goto TOUPIAO;
		
	}
	
	cout<<idx_max+1<<"号"<<"出局\n";
	Sleep(4000);
	players[idx_max].die_or_life = die;
	players[idx_max].killer = good;
	return idx_max;
}
 
/*警长死亡*/
void police_die(){
	color(yellow);
	int type;
	if(idx_police==my_number)
	{
		Sleep(1550);
		cout<<"你是想撕毁警徽还是移交警徽?(撕毁输入1,移交输入2)";
		
		cin>>type;
		while(!(type==1||type==2))
		{
			cout<<"请重新输入!\n";
			cin>>type;
		}
	}
	else{
		type=rand()%3+1;
	}
	if(type==1)
	{
		cout<<"警长选择撕毁警徽\n";
		Sleep(1000);
		idx_police=-1;
	}
	else
	{
		int lucky=-1;
		while(lucky==-1||players[lucky].die_or_life==die)
			lucky=rand()%player_number;
		cout<<"警长选择把警徽移交给"<<lucky+1<<"号\n";
		Sleep(1500);
		idx_police=lucky; 
	}
}
 
/*故事的最后*/
void the_end(){
	system("cls");
	switch(is_end()){
		case 1:cout<<"好人胜利\n\n"; break;
		case 2:cout<<"狼人胜利\n\n"; break;
		case 3:cout<<"本局平局\n\n"; break;
	}
	for(int i=0;i<player_number;i++){
		cout<<i+1<<"号位:\t";
		switch(players[i].type){
			case nvwu: cout<<"女巫\t";break;
			case yuyanjia: cout<<"预言家\t";break;
			case cunmin: cout<<"村民\t";break;
			case langren:cout<<"狼人\t";break;
			case lieren:cout<<"猎人\t"; break;  
			case shouwei:cout<<"守卫\t";break;  
		} 
		cout<<"最终";
		switch(players[i].killer){
			case nvwu:cout<<"被女巫毒死\n"; break;
			case langren:cout<<"被狼人杀死\n"; break;
			case good:cout<<"被投票出局\n"; break;
			case lieren:cout<<"被猎人带走\n";break;
			default :cout<<"存活\n";
		}
		cout<<endl;
	}
}
 
/*主函数*/
int main(){
	int wheel=0; 
	before_game();
	while(!is_end()){
		//黑夜准备 
		something_before_everyday();
		Sleep(1500); 
		
		//黑夜部分 
		Night(); //进入黑夜! 
		change_daytime(); //换天 
		
		//天亮了 
		panduansiwang();//判断谁死了 
		Sleep(2000);
		system("cls");
		print();
		if(is_end()) break;
		
		//选警长 
		if(!wheel&&player_number==12)
		{
			choose_police();
			system("cls");
			print();
		}
		
		//投票环节 
		int idx_max=toupiao();//票数最多的人 
		if(idx_max==idx_police){
			police_die();
		}
		if(players[idx_max].type==lieren){//启动猎人程序 
			Lieren();
			if(is_end()) break;
		}
		system("cls");
		print(); 
		wheel++;
	}
	
	the_end();
	system("pause");
	return 0;
}

俄罗斯方块

C++
//俄罗斯方块(最终版)
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
#include <windows.h>
#include <conio.h>
using namespace std;

int block00[4][4] = { { 10, 0, 0, 0 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } };
int block01[4][4] = { { 11, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 } };
int block02[4][4] = { { 12, 0, 0, 0 }, { 0, 0, 0, 0 }, { 1, 1, 1, 0 }, { 0, 1, 0, 0 } };
int block03[4][4] = { { 13, 0, 0, 0 }, { 0, 1, 0, 0 }, { 1, 1, 0, 0 }, { 0, 1, 0, 0 } };
int block04[4][4] = { { 14, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 }, { 1, 1, 1, 0 } };
int block05[4][4] = { { 15, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 } };
int block06[4][4] = { { 16, 0, 0, 0 }, { 0, 0, 0, 0 }, { 1, 1, 1, 0 }, { 1, 0, 0, 0 } };
int block07[4][4] = { { 17, 0, 0, 0 }, { 1, 1, 0, 0 }, { 0, 1, 0, 0 }, { 0, 1, 0, 0 } };
int block08[4][4] = { { 18, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 1, 0 }, { 1, 1, 1, 0 } };
int block09[4][4] = { { 19, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 1, 0, 0 }, { 0, 1, 1, 0 } };
int block10[4][4] = { { 20, 0, 0, 0 }, { 0, 0, 0, 0 }, { 1, 1, 1, 0 }, { 0, 0, 1, 0 } };
int block11[4][4] = { { 21, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 1, 0, 0 }, { 1, 1, 0, 0 } };
int block12[4][4] = { { 22, 0, 0, 0 }, { 0, 0, 0, 0 }, { 1, 0, 0, 0 }, { 1, 1, 1, 0 } };
int block13[4][4] = { { 23, 0, 0, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 1, 0, 0 } };
int block14[4][4] = { { 24, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 1, 1, 0, 0 } };
int block15[4][4] = { { 25, 0, 0, 0 }, { 1, 0, 0, 0 }, { 1, 1, 0, 0 }, { 0, 1, 0, 0 } };
int block16[4][4] = { { 26, 0, 0, 0 }, { 0, 0, 0, 0 }, { 1, 1, 0, 0 }, { 0, 1, 1, 0 } };
int block17[4][4] = { { 27, 0, 0, 0 }, { 0, 0, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 } };
int block18[4][4] = { { 28, 0, 0, 0 }, { 0, 0, 0, 0 }, { 1, 1, 0, 0 }, { 1, 1, 0, 0 } };

void initialWindow (HANDLE hOut);//初始化窗口
void initialPrint (HANDLE hOut);//初始化界面
void gotoXY (HANDLE hOut, int x, int y);//移动光标
void roundBlock (HANDLE hOut, int block[4][4]);//随机生成方块并打印到下一个方块位置
bool collisionDetection (int block[4][4], int map[21][12], int x, int y);//检测碰撞
void printBlock (HANDLE hOut, int block[4][4], int x, int y, bool isNextBlock = false);//打印方块
void clearBlock (HANDLE hOut, int block[4][4], int x, int y);//消除方块
void myLeft (HANDLE hOut, int block[4][4], int map[21][12], int x, int &y);//左移
void myRight (HANDLE hOut, int block[4][4], int map[21][12], int x, int &y);//右移
void myUp (HANDLE hOut, int block[4][4], int map[21][12], int x, int &y);//顺时针旋转90度
int myDown (HANDLE hOut, int block[4][4], int map[21][12], int &x, int y);//加速下落
void myStop (HANDLE hOut, int block[4][4]);//游戏暂停
void gameOver (HANDLE hOut, int block[4][4], int map[21][12]);//游戏结束
//判断是否能消行并更新分值
void eliminateRow (HANDLE hOut, int map[21][12], int &val, int &fraction, int &checkpoint);

int main () {
    MessageBox (NULL, "欢迎来到俄罗斯方块游戏!", "温馨提示", MB_OK);
    system ("mode con cols=70 lines=35");
    
    int map[21][12];
    int blockA[4][4];//候选区的方块
    int blockB[4][4];//下落中的方块
    int positionX, positionY;//方块左上角的坐标
    bool check;//检查方块还能不能下落
    char key;//用来存储按键
    int val;//用来控制下落速度
    int fraction;//用来存储得分
    int checkpoint;//用来存储关卡
    int times;
    
    HANDLE hOut = GetStdHandle (STD_OUTPUT_HANDLE);//获取标准输出设备句柄
    initialWindow (hOut);
    
	initial:
    gotoXY (hOut, 0, 0);
    initialPrint (hOut);
    check = true;
    val = 50;
    fraction = 0;
    checkpoint = 1;
    times = val;
    
    for (int i = 0; i < 20; i++) {
        for (int j = 1; j < 11; j++) {
            map[i][j] = 0;
        }
    }
    
    for (int i = 0; i < 20; i++) {
        map[i][0] = map[i][11] = 1;
    }
    
    for (int i = 0; i < 12; i++) {
        map[20][i] = 1;
    }
    
    srand ((unsigned) time (NULL));
    roundBlock (hOut, blockA);
    
    while (true) {
        if (check) {
            eliminateRow (hOut, map, val, fraction, checkpoint);
            check = false;
            positionX = -3;
            positionY = 4;
            if (collisionDetection (blockA, map, positionX, positionY)) {
                for (int i = 0; i < 4; i++) {
                    for (int j = 0; j < 4; j++) {
                        blockB[i][j] = blockA[i][j];
                    }
                }
                roundBlock (hOut, blockA);
            } else {
                gameOver (hOut, blockA, map);
                goto initial;
            }
        }
        
        printBlock(hOut, blockB, positionX, positionY); 
        
        if (_kbhit ()) {
            key = _getch ();
            switch (key) {
                case 72:
                    myUp (hOut, blockB, map, positionX, positionY);
                    break;
                case 75:
                    myLeft (hOut, blockB, map, positionX, positionY);
                    break;
                case 77:
                    myRight (hOut, blockB, map, positionX, positionY);
                    break;
                case 80:
                    switch (myDown (hOut, blockB, map, positionX, positionY)) {
                        case 0:
                            check = false;
                            break;
                        case 1:
                            check = true;
                            break;
                        case 2:
                            gameOver (hOut, blockB, map);
                            goto initial;
                        default:
                            break;
                    }
                    break;
                case 32:
                    myStop (hOut, blockA);
                    break;
                case 27:
                    exit (0);
                default:
                    break;
            }
        }
        
        Sleep (20);
        if (--times == 0) {
            switch (myDown (hOut, blockB, map, positionX, positionY)) {
                case 0:
                    check = false;
                    break;
                case 1:
                    check = true;
                    break;
                case 2:
                    gameOver (hOut, blockB, map);
                    goto initial;
                default:
                    break;
            }
            times = val;
        }
    }
    
    cin.get ();
    return 0;
}

void initialWindow (HANDLE hOut) {
	SetConsoleTitle ("俄罗斯方块");
	COORD size = { 80, 25 };
	SetConsoleScreenBufferSize (hOut, size);
	SMALL_RECT rc = { 0, 0, 79, 24 };
	SetConsoleWindowInfo (hOut, true, &rc);
	CONSOLE_CURSOR_INFO cursor_info = { 1, 0 };
	SetConsoleCursorInfo (hOut, &cursor_info);
}
 
void initialPrint(HANDLE hOut) {
	SetConsoleTextAttribute(hOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    for (int i = 0; i < 20; i++) {
        // 明确绘制左右边界
        gotoXY(hOut, 0, i);       // 左边界(列0)
        cout << "■";
        gotoXY(hOut, 2*11, i);    // 右边界(列11)
        cout << "■";
        
        // 填充中间活动区域和右侧信息区
        gotoXY(hOut, 2, i);
        cout << "                    ";
        gotoXY(hOut, 24, i);
        cout << "☆                      ☆";
    }
    // 底部边界
    gotoXY(hOut, 0, 20);
    cout << "■■■■■■■■■■■■";
    gotoXY(hOut, 24, 20);
    cout << "☆☆☆☆☆☆☆☆☆☆☆☆☆";
    
	gotoXY (hOut, 26, 0);
	gotoXY (hOut, 0, 20);
	cout << "■■■■■■■■■■■■☆☆☆☆☆☆☆☆☆☆☆☆☆";
	gotoXY (hOut, 26, 1);
	cout << "分    数:      ";
	gotoXY (hOut, 26, 2);
	cout << "关    卡:      ";
	gotoXY (hOut, 26, 4);
	cout << "下一方块:";
	gotoXY (hOut, 26, 9);
	cout << "操作方法:";
	gotoXY (hOut, 30, 11);
	cout << "↑:旋转 ↓:速降";
	gotoXY (hOut, 30, 12);
	cout << "→:右移 ←:左移";
	gotoXY (hOut, 30, 13);
	cout << "空格键:开始/暂停";
	gotoXY (hOut, 30, 14);
	cout << "Esc 键:退出";
	gotoXY (hOut, 26, 16);
	cout << "关    于:";
	gotoXY (hOut, 30, 18);
	cout << "俄罗斯方块V1.0";
	gotoXY (hOut, 35, 19);
}
void gotoXY (HANDLE hOut, int x, int y) {
	COORD pos;
	pos.X = x;
	pos.Y = y;
	SetConsoleCursorPosition (hOut, pos);
}
void roundBlock(HANDLE hOut, int block[4][4]) {
	clearBlock (hOut, block, 5, 15);
	switch (rand() % 19) {
		case 0:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block00[i][j];
				}
			}
			break;
		case 1:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block01[i][j];
				}
			}
			break;
		case 2:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block02[i][j];
				}
			}
			break;
		case 3:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block03[i][j];
				}
			}
			break;
		case 4:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block04[i][j];
				}
			}
			break;
		case 5:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block05[i][j];
				}
			}
			break;
		case 6:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block06[i][j];
				}
			}
			break;
		case 7:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
				block[i][j] = block07[i][j];
			}
		}
		break;
		case 8:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block08[i][j];
				}
			}
			break;
		case 9:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++)
				{
					block[i][j] = block09[i][j];
				}
			}
			break;
		case 10:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block10[i][j];
				}
			}
			break;
		case 11:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block11[i][j];
				}
			}
			break;
		case 12:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block12[i][j];
				}
			}
			break;
		case 13:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block13[i][j];
				}
			}
			break;
		case 14:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block14[i][j];
				}
			}
			break;
		case 15:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block15[i][j];
				}
			}
			break;
		case 16:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block16[i][j];
				}
			}
			break;
		case 17:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block17[i][j];
				}
			}
			break;
		case 18:
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					block[i][j] = block18[i][j];
				}
			}
			break;
		default:
			break;
	}
	printBlock(hOut, block, 5, 15, true);
}
// 新增:重新绘制边界函数
void redrawBorders(HANDLE hOut) {
    SetConsoleTextAttribute(hOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    for (int i = 0; i < 20; i++) {
        gotoXY(hOut, 0, i);       // 左边界
        cout << "■";
        gotoXY(hOut, 2*11, i);    // 右边界
        cout << "■";
    }
    gotoXY(hOut, 0, 20);         // 底部边界
    cout << "■■■■■■■■■■■■";
}
bool collisionDetection (int block[4][4], int map[21][12], int x, int y) {
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			if (x + i >= 0 && y + j >= 0 && y + j < 12 && map[x + i][y + j] == 1 && block[i][j] == 1) {
				return false;
			}
		}
	}
	return true;
}
void printBlock (HANDLE hOut, int block[4][4], int x, int y, bool isNextBlock) {
	switch (block[0][0]) {
		case 10:
		case 11:
			SetConsoleTextAttribute (hOut, FOREGROUND_GREEN);
			break;
		case 12:
		case 13:
		case 14:
		case 15:
			SetConsoleTextAttribute (hOut, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
			break;
		case 16:
		case 17:
		case 18:
		case 19:
			SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
			break;
		case 20:
		case 21:
		case 22:
		case 23:
			SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
			break;
		case 24:
		case 25:
			SetConsoleTextAttribute (hOut, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
			break;
		case 26:
		case 27:
			SetConsoleTextAttribute (hOut, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
			break;
		case 28:
			SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_INTENSITY);
			break;
		default:
			break;
	}
	for (int i = 0; i < 4; i++) {
        int row = x + i;
        if (row < 0 || row >= 35) continue; // 仅限制行不超出窗口,不限制列

        for (int j = 0; j < 4; j++) {
            int col = y + j;
            if (block[i][j] == 1) {
                // 游戏中的方块限制列范围(1-10),下一个方块无限制
                if (!isNextBlock && (col < 1 || col > 10)) {
                    continue;
                }
                gotoXY(hOut, 2 * col, row);
                cout << "■";
            }
        }
    }
}
void clearBlock(HANDLE hOut, int block[4][4], int x, int y) {
    for (int i = 0; i < 4; i++) {
        int row = x + i;
        if (row < 0) continue;
        for (int j = 0; j < 4; j++) {
            int col = y + j;
            if (block[i][j] == 1) {
                // 清除下一个方块时不限制列范围
                if (x != 5 && (col < 1 || col > 10)) { 
                    continue;
                }
                gotoXY(hOut, 2 * col, row);
                cout << "  ";
            }
        }
    }
}
void gameOver (HANDLE hOut, int block[4][4], int map[21][12]) {
	SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_INTENSITY);
	gotoXY (hOut, 9, 8);
	string s = "GAME OVER";
	for (int i = 0; i < s.size (); i++) {
		Sleep (80);
		cout << s[i];
	}
	gotoXY (hOut, 8, 9);
	s = "空格键:重来";
	for (int i = 0; i < s.size (); i++) {
		Sleep (80);
		cout << s[i];
	}
	cout << endl;
	gotoXY (hOut, 8, 10);
	s = "ESC键:退出";
	MessageBox (NULL, "很遗憾,您输了!", "温馨提示", MB_OK);
	for (int i = 0; i < s.size (); i++) {
		Sleep (80);
		cout << s[i];
	}
	char key;
	while (true) {
		key = _getch ();
		if (key == 32) {
			return;
		} else if (key == 27) {
			exit(0);
		}
	}
}
int myDown (HANDLE hOut, int block[4][4], int map[21][12], int &x, int y) {
	if (collisionDetection(block, map, x + 1, y)) {
        clearBlock (hOut, block, x, y);
        ++x;
        printBlock(hOut, block, x, y);
        redrawBorders(hOut); // 新增:移动后重新绘制边界
        return 0;
    }
	if (x < 0) {
		return 2;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			if (block[i][j] == 1) {
				map[x + i][y + j] = 1;
				SetConsoleTextAttribute (hOut, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
				gotoXY (hOut, 2 * (y + j), x + i);
				cout << "■";
			}
		}
	}
	redrawBorders(hOut); // 新增:方块固定后重新绘制边界
    return 1;
}
void myLeft (HANDLE hOut, int block[4][4], int map[21][12], int x, int &y) {
	if (collisionDetection (block, map, x, y - 1)) {
		clearBlock (hOut, block, x, y);
		--y;
		printBlock(hOut, block, x, y);
		redrawBorders(hOut);
	}
}
void myRight (HANDLE hOut, int block[4][4], int map[21][12], int x, int &y) {
	if (collisionDetection (block, map, x, y + 1)) {
		clearBlock (hOut, block, x, y);
		++y;
		printBlock(hOut, block, x, y);
		redrawBorders(hOut);
	}
}
void myUp (HANDLE hOut, int block[4][4], int map[21][12], int x, int &y) {
	switch (block[0][0]) {
		case 10:
			if (collisionDetection (block01, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block01[i][j];
					}
				}
			}
			break;
		case 11:
			if (collisionDetection (block00, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block00[i][j];
					}
				}
			} else if (collisionDetection (block00, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block00[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block00, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block00[i][j];
					}
				}
				++y;
			} else if (collisionDetection (block00, map, x, y - 2)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block00[i][j];
					}
				}
				y -= 2;
			} else if (collisionDetection (block00, map, x, y + 2)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block00[i][j];
					}
				}
				y += 2;
			}
			break;
		case 12:
			if (collisionDetection (block03, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block03[i][j];
					}
				}
			} else if (collisionDetection (block03, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block03[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block03, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block03[i][j];
					}
				}
				++y;
			}
			break;
		case 13:
			if (collisionDetection (block04, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block04[i][j];
					}
				}
			} else if (collisionDetection (block04, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block04[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block04, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block04[i][j];
					}
				}
				++y;
			}
			break;
		case 14:
			if (collisionDetection (block05, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block05[i][j];
					}
				}
			} else if (collisionDetection (block05, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block05[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block05, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block05[i][j];
					}
				}
				++y;
			}
			break;
		case 15:
			if (collisionDetection (block02, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block02[i][j];
					}
				}
			} else if (collisionDetection (block02, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block02[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block02, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block02[i][j];
					}
				}
				++y;
			}
			break;
		case 16:
			if (collisionDetection (block07, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block07[i][j];
					}
				}
			} else if (collisionDetection (block07, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block07[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block07, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block07[i][j];
					}
				}
				++y;
			}
			break;
		case 17:
			if (collisionDetection (block08, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block08[i][j];
					}
				}
			} else if (collisionDetection (block08, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block08[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block08, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block08[i][j];
					}
				}
				++y;
			}
			break;
		case 18:
			if (collisionDetection (block09, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block09[i][j];
					}
				}
			} else if (collisionDetection (block09, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block09[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block09, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block09[i][j];
					}
				}
				++y;
			}
			break;
		case 19:
			if (collisionDetection (block06, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block06[i][j];
					}
				}
			} else if (collisionDetection (block06, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block06[i][j];
					}
				}
				--y;
			} else if (collisionDetection(block06, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block06[i][j];
					}
				}
				++y;
			}
			break;
		case 20:
			if (collisionDetection (block11, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block11[i][j];
					}
				}
			} else if (collisionDetection (block11, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++)	{
					for (int j = 0; j < 4; j++)	{
						block[i][j] = block11[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block11, map, x, y + 1))	{
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++)	{
					for (int j = 0; j < 4; j++)	{
						block[i][j] = block11[i][j];
					}
				}
				++y;
			}
			break;
		case 21:
			if (collisionDetection (block12, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++)	{
						block[i][j] = block12[i][j];
					}
				}
			} else if (collisionDetection(block12, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block12[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block12, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block12[i][j];
					}
				}
				++y;
			}
			break;
		case 22:
			if (collisionDetection (block13, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block13[i][j];
					}
				}
			} else if (collisionDetection (block13, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block13[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block13, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block13[i][j];
					}
				}
				++y;
			}
			break;
		case 23:
			if (collisionDetection (block10, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block10[i][j];
					}
				}
			} else if (collisionDetection (block10, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block10[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block10, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block10[i][j];
					}
				}
				++y;
			}
			break;
		case 24:
			if (collisionDetection (block15, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block15[i][j];
					}
				}
			} else if (collisionDetection (block15, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block15[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block15, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block15[i][j];
					}
				}
				++y;
			}
			break;
		case 25:
			if (collisionDetection (block14, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block14[i][j];
					}
				}
			} else if (collisionDetection (block14, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block14[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block14, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block14[i][j];
					}
				}
				++y;
			}
			break;
		case 26:
			if (collisionDetection (block17, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block17[i][j];
					}
				}
			} else if (collisionDetection (block17, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) block[i][j] = block17[i][j];
				}
				--y;
			} else if (collisionDetection (block17, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) block[i][j] = block17[i][j];
				}
				++y;
			}
			break;
		case 27:
			if (collisionDetection (block16, map, x, y)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block16[i][j];
					}
				}
			} else if (collisionDetection (block16, map, x, y - 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) {
						block[i][j] = block16[i][j];
					}
				}
				--y;
			} else if (collisionDetection (block16, map, x, y + 1)) {
				clearBlock (hOut, block, x, y);
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 4; j++) block[i][j] = block16[i][j];
				}
				++y;
			}
			break;
		default:
			break;
	}
}
void myStop (HANDLE hOut, int block[4][4]) {
	clearBlock (hOut, block, 5, 15);
	SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_INTENSITY);
	gotoXY (hOut, 30, 7);
	cout << "游戏暂停";
	char key;
	while (true) {
		key = _getch ();
		if (key == 32) {
			gotoXY (hOut, 30, 7);
			cout << "        ";
			printBlock(hOut, block, 5, 15, true);
			return;
		} else if (key == 27) {
			exit(0);
		}
	}
}
void eliminateRow (HANDLE hOut, int map[21][12], int &val, int &fraction, int &checkpoint) {
	int count = 0;
	for (int i = 19; i >= 0; i--) {
		bool isFull = true;
		for (int j = 1; j < 11; j++) {
			if (map[i][j] == 0) {
				isFull = false;
				break;
			}
		}
		if (isFull) {
			++count;
			for (int k = i; k > 0; k--) {
				for (int j = 1; j < 11; j++) {
					map[k][j] = map[k - 1][j];
				}
			}
			for (int j = 1; j < 11; j++) {
				map[0][j] = 0;
			}
			++i;
		}
	}
	if (count > 0) {
		fraction += count * 100;
		checkpoint = fraction / 1000 + 1;
		if (checkpoint > 10) checkpoint = 10;
		val = 50 - (checkpoint - 1) * 5;
		if (val < 5) val = 5;
		SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
		gotoXY (hOut, 34, 1);
		cout << fraction;
		gotoXY (hOut, 34, 2);
		cout << checkpoint;
	}
}

愤怒的小鸟

C++
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
using namespace std;
const double pi=3.1415926536;
int toint(float a){return ((int)(a*10+5))/10;}
void Color(int a)
{
    if(a==0||a==14||a==20) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    if(a==1||a==12) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
    if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
    if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
    if(a==4||a==11) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
    if(a==5||a==13) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
    if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN|FOREGROUND_BLUE);
    if(a==15) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);
    if(a==16) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN);
    if(a==17) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
    if(a==8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
    if(a==9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|BACKGROUND_RED|BACKGROUND_GREEN);
}
void SetPos(float x,float y)
{
    int xx=toint(x),yy=toint(y);
    COORD pos;pos.X=yy*2,pos.Y=xx;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
struct node
{
    int W,W2,S,mS;
    float X,Y;
    float vx,vy;
    float ax,ay;
    bool go,boom;
}blt[100001],pig[100001],boo[100001];
int T,yX,yY,Xy,put,K,K2,Sle,What;
int Bot,Pit,Blt,Pig,Sco,pigk,scok;
int m[41][41];
void Cout(int a,int x,int y)
{
    if(a==1) SetPos(x,y),Color(5),cout<<put<<' ';
    if(y==202)
    {
        SetPos(pig[a].X,pig[a].Y);cout<<"  ";
        if((pig[a].W==2||pig[a].W==3)&&pig[a].X>=2) SetPos(pig[a].X-2,pig[a].Y);cout<<"  ",SetPos(pig[a].X-1,pig[a].Y);cout<<"  ";
        if(pig[a].W==4) SetPos(pig[a].X,pig[a].Y-1),cout<<"  "; 
        if(pig[a].W==5) SetPos(pig[a].X-1,pig[a].Y),cout<<"  ",SetPos(pig[a].X-1,pig[a].Y-1),cout<<"  ";
    }
    if(a==2)
    for(int i=0;i<=40;i++)
    for(int j=0;j<=40;j++)
    {
        if(i<=18&&m[i][j]==1) SetPos(i,j),Color(7),cout<<"■";
        if(m[i][j]>=2&&m[i][j]<=19) SetPos(i,j),Color(5),cout<<"█",m[i][j]++;
        if(m[i][j]>19&&m[i][j]<=29) SetPos(i,j),Color(0),cout<<"█",m[i][j]++;
        if(m[i][j]==30) SetPos(i,j),Color(0),cout<<"  ",m[i][j]=0;
        if(m[i][j]>=31&&m[i][j]<=49) SetPos(i,j),Color(0),cout<<"■",m[i][j]++;
        if(m[i][j]==50) SetPos(i,j),Color(7),cout<<"■",m[i][j]=1;
    }
    if(y==666)
    {
        SetPos(blt[a].X,blt[a].Y);
        Color(10+blt[a].W),cout<<"●";
    }Color(0);
}
void Go(int a)
{
    SetPos(blt[a].X,blt[a].Y);cout<<"  ";
    blt[a].X+=blt[a].vx/2;blt[a].Y+=blt[a].vy/2;blt[a].vx+=blt[a].ax/2;blt[a].vy+=blt[a].ay/2;
    if(blt[a].X>=20) blt[a].X=19;
    if(blt[a].X>20||blt[a].Y>38||blt[a].X<0||blt[a].Y<=0) blt[a].go=1;
    if(blt[a].W2==1&&blt[a].Y>=Xy) blt[a].go=1,Sle=0;//地跑鸟
    if(blt[a].W2==0)
    {
        for(int i=0;i<=blt[a].vx/2+1;i++)
        {
            if(blt[a].vx>0&&m[toint(blt[a].X)+i][toint(blt[a].Y)]==1) //上反弹 
            {
                if(blt[a].W!=5) blt[a].boom=1;
                blt[a].X=toint(blt[a].X)+i-1,blt[a].Y+=blt[a].vy/2,blt[a].vx=-blt[a].vx*0.4,blt[a].vy=blt[a].vy*0.8;
                if(blt[a].W==3) blt[a].ax=0.5;if(blt[a].W==7) blt[a].vx*=2;
                if(blt[a].W==10) blt[a].go=1,Bot++,boo[Bot].X=blt[a].X,boo[Bot].Y=blt[a].Y,boo[Bot].S=1,boo[Bot].mS=4;
            }
            if(blt[a].vx<0&&m[toint(blt[a].X)-i][toint(blt[a].Y)]==1) //下反弹 
            {
                if(blt[a].W!=5) blt[a].boom=1;
                blt[a].X=toint(blt[a].X)+i+1,blt[a].Y+=blt[a].vy/2,blt[a].vx=-blt[a].vx,blt[a].vy=blt[a].vy*0.8;
                if(blt[a].W==3) blt[a].ax=0.5;if(blt[a].W==7) blt[a].vx*=2;
                if(blt[a].W==10) blt[a].go=1,Bot++,boo[Bot].X=blt[a].X,boo[Bot].Y=blt[a].Y,boo[Bot].S=1,boo[Bot].mS=4;
            }
        }
        if(abs(blt[a].vx)<=0.1&&abs(blt[a].vy)<=0.1&&abs(blt[a].ay)<=0.1)
        {
            blt[a].go=1;
            if(blt[a].W==5) Bot++,boo[Bot].X=blt[a].X,boo[Bot].Y=blt[a].Y,boo[Bot].S=1,boo[Bot].mS=4,blt[a].go=1;
        }
    }
    if(blt[a].go==0) Cout(a,0,666);
}
void Kill(int a)
{
    if(pig[a].go==0&&pig[a].W!=2&&pig[a].W!=3&&pig[a].Y<16) Cout(a,202,202),pig[a].Y=16;
    if(pig[a].go==0&&pig[a].W==4&&pig[a].Y<20) pig[a].W=1;
    int R=rand()%50;Cout(a,202,202);
    /////////清除猪猪 
    pig[a].X+=pig[a].vx/2;pig[a].Y+=pig[a].vy/2;pig[a].vx+=pig[a].ax/2;pig[a].vy+=pig[a].ay/2;
    for(int i=-2;i<=pig[a].vx/2+1;i++)
    {
        if(m[toint(pig[a].X)+i][toint(pig[a].Y)]==1) //上反弹 
        pig[a].X=toint(pig[a].X)+i-1,pig[a].Y+=pig[a].vy/2,pig[a].vx=-pig[a].vx*0.5,pig[a].vy=pig[a].vy*0.8;
    }
    for(int i=Blt-10;i<=Blt;i++)
    {
        if(pig[a].W==5&&blt[i].go==0&&abs(pig[a].X-blt[i].X)<=1&&abs(pig[a].Y-blt[i].Y)<=1) {m[toint(pig[a].X)-1][toint(pig[a].Y)]=2,pig[a].W2++;Sco+=2;break;}
        if(pig[a].W==5&&m[toint(pig[a].X)][toint(pig[a].Y)]>=2&&m[toint(pig[a].X)][toint(pig[a].Y)]<30) {m[toint(pig[a].X)-1][toint(pig[a].Y)]=2,pig[a].W2++;Sco+=2;break;}
        if(blt[i].go==0&&abs(pig[a].X-blt[i].X)<=1&&abs(pig[a].Y-blt[i].Y)<=1)
        {
            if(pig[a].W==6) Bot++,boo[Bot].X=pig[a].X,boo[Bot].Y=pig[a].Y,boo[Bot].S=1,boo[Bot].mS=4,blt[i].go=1;
            m[toint(pig[a].X)][toint(pig[a].Y)]=2,pig[a].go=1,Pig--,Sco+=10;break;
        }
        if(m[toint(pig[a].X)][toint(pig[a].Y)]>=2&&m[toint(pig[a].X)][toint(pig[a].Y)]<30)
        {
            if(pig[a].W==6) Bot++,boo[Bot].X=pig[a].X,boo[Bot].Y=pig[a].Y,boo[Bot].S=1,boo[Bot].mS=4;
            pig[a].go=1,Pig--,Sco+=10;break;
        }
        if((pig[a].W==2||pig[a].W==3)&&blt[i].go==0&&abs(pig[a].X-2-blt[i].X)<=1&&abs(pig[a].Y-blt[i].Y)<=1) {m[toint(pig[a].X)][toint(pig[a].Y)]=2,pig[a].go=1,Pig--,Sco+=10;break;}
        if((pig[a].W==2||pig[a].W==3)&&m[toint(pig[a].X-2)][toint(pig[a].Y)]>=2&&m[toint(pig[a].X-2)][toint(pig[a].Y)]<30) {pig[a].go=1,Pig--,Sco+=10;break;}
    }
    /////////弄死猪猪 
    if(pig[a].go==0)
    {
        if(pig[a].go==0&&pig[a].W!=2&&pig[a].W!=3&&pig[a].Y<16) Cout(a,202,202),pig[a].Y=16;
        if(pig[a].go==0&&pig[a].W==4&&pig[a].Y<20) pig[a].W=1;
        int Xx=toint(pig[a].X),Xy=toint(pig[a].Y);
        if(pig[a].W==6) SetPos(pig[a].X,pig[a].Y),Color(9),cout<<"TN",Color(0);
        else{
        SetPos(pig[a].X,pig[a].Y),Color(2),cout<<"●";
        if((pig[a].W==2||pig[a].W==3)&&pig[a].X>=2) SetPos(pig[a].X-2,pig[a].Y),Color(0),cout<<"○",SetPos(pig[a].X-1,pig[a].Y),cout<<"|";
        if(pig[a].W==4) SetPos(pig[a].X,pig[a].Y-1),Color(2),cout<<"﹃";
        if(pig[a].W==5)
        {
            SetPos(pig[a].X-1,pig[a].Y),Color(8);SetPos(pig[a].X-1,pig[a].Y-1),cout<<"▁";
            if(pig[a].W2==0)cout<<"▅";if(pig[a].W2==1)cout<<"▃";if(pig[a].W2==2)cout<<"▂";if(pig[a].W2==3) pig[a].W=1,pig[a].W2=0,SetPos(pig[a].X-1,pig[a].Y-1),cout<<"  ";
        }
        }
        /////////输出猪猪 
        if(pig[a].W==2&&pig[a].X>pig[a].S) pig[a].W=3,pig[a].ax=-0.4,pig[a].vx=1.5;
        else if(pig[a].W==3&&pig[a].X<=pig[a].S) pig[a].W=2,pig[a].ax=0.4,pig[a].vx=-1.5;
        if((pig[a].W==2||pig[a].W==3)&&(pig[a].Y<=10||pig[a].Y>=38)) pig[a].vy*=-1;
        if(pig[a].W==4&&R==0&&pig[a].X==20) pig[a].vx=-((rand()%40)/10);
        if(pig[a].W==4)
        {
            int r=rand()%20;
            for(int i=Blt-10;i<=Blt;i++) if(r<=5&&blt[i].go==0&&pig[a].Y-blt[i].Y<=5&&abs(blt[i].X-pig[a].X)<=1.5&&r<5) r=0;
            if(r==0)
            {
                m[toint(pig[a].X)][toint(pig[a].Y)-2]=10;m[toint(pig[a].X)][toint(pig[a].Y)-3]=2;
                for(int j=toint(pig[a].Y)-1;j>=toint(pig[a].Y)-5;j--)
                {
                    for(int i=Blt-10;i<=Blt;i++) if(blt[i].go==0&&!(blt[i].W==3&&blt[i].boom==1)&&blt[i].W2==0&&toint(blt[i].Y)==j&&abs(blt[i].X-pig[a].X)<=2) blt[i].vy=-2;
                    for(int i=Pit-50;i<=Pit;i++) if(pig[i].go==0&&toint(pig[i].Y)==j&&abs(pig[i].X-pig[a].X)<=2) pig[i].vy=-1;
                }
            }
        }
        /////////移动猪猪 
        if(pig[a].go==0&&pig[a].W!=2&&pig[a].W!=3&&pig[a].Y<16) Cout(a,202,202),pig[a].Y=16;
        if(pig[a].go==0&&pig[a].W==4&&pig[a].Y<20) pig[a].W=1;
        if(pig[a].X>20||pig[a].Y>38||pig[a].X<0||pig[a].Y<=0) pig[a].go=1,Pig--,Cout(a,202,202);
        /////////清除猪猪 
    }
}
void Creat(int a,int p)
{
    if(a==-1&&p==-1)
    {
        Blt++;blt[Blt].W=What;blt[Blt].W2=1;
        blt[Blt].vy=1;blt[Blt].X=19;blt[Blt].Y=0;blt[Blt].boom=1;
    }
    else if(a==0&&p==-1)
    {
        int u=rand()%7+1,U=rand()%30;
        if(u>=5) Pit++,pig[Pit].Y=rand()%15+20,pig[Pit].X=2,pig[Pit].ax=0.5,pig[Pit].W=1;
        if(u==1) Pit++,pig[Pit].Y=rand()%15+20,pig[Pit].X=2,pig[Pit].vy=0.5,pig[Pit].ax=0.5,pig[Pit].S=rand()%5+7,pig[Pit].W=2;
        if(u==2) Pit++,pig[Pit].Y=rand()%15+20,pig[Pit].X=2,pig[Pit].ax=0.5,pig[Pit].W=4;
        if(u==3) Pit++,pig[Pit].Y=rand()%15+20,pig[Pit].X=2,pig[Pit].ax=0.5,pig[Pit].W=5;
        if(u==4) Pit++,pig[Pit].Y=rand()%15+20,pig[Pit].X=2,pig[Pit].ax=0.5,pig[Pit].W=6;
        if(U==1) Bot++,boo[Bot].Y=rand()%13+15,boo[Bot].X=(rand()%4)*3+8,boo[Bot].S=0,boo[Bot].mS=rand()%2+2,boo[Bot].W2=1;
    }
    else
    {
        Blt++;blt[Blt].W=What;
        if(a==1) blt[Blt].X=yX;blt[Blt].Y=yY;blt[Blt].ax=0.5; //抛物线
        blt[Blt].vx=-3.5*sin(p*pi/180);
        blt[Blt].vy=3*cos(p*pi/180);
        if(p<=45) blt[Blt].vy*=1+(0.33-0.01*(45-p));
        if(p>=45) blt[Blt].vy*=1+(0.33-0.01*(p-45));
        if(blt[Blt].W==6) blt[Blt].vy*=1.2,blt[Blt].ax=0.4;
    }
}
void Boom(int a)
{
    if(boo[a].W2==0)
    {
        int ms=boo[a].mS,s=boo[a].S,x=boo[a].X,y=boo[a].Y;
        if(s==ms) return;
        for(int i=x-s;i<=x+s;i++)
        for(int j=y-s;j<=y+s;j++)
        {
            float k=(i-x)*(i-x)+(j-y)*(j-y)-s*s;
            if(k<=s&&k>=-s&&i<=20&&j<=38&&i>=0&&j>0&&m[i][j]!=1) m[i][j]=2;
        }boo[a].S++;
    }
    if(boo[a].W2==1)
    {
        int ms=boo[a].mS,s=boo[a].S,x=boo[a].X,y=boo[a].Y;
        if(s==ms) return;
        if(y-s>10) m[x][y-s]=31-31*(boo[a].W2-1);
        if(y+s<40) m[x][y+s]=31-31*(boo[a].W2-1);
        boo[a].S++;
    }
}
void Move(int a)
{
    Color(5);
    if(a==-2) SetPos(17,Xy),cout<<"        ",SetPos(18,Xy),cout<<"        ",SetPos(19,Xy),cout<<"        ",SetPos(20,Xy),cout<<"       ";
    if(a==-1) SetPos(17,Xy),cout<<"        ",SetPos(18,Xy),cout<<"  ┃  ┃",SetPos(19,Xy),cout<<"  ╰┳╯",SetPos(20,Xy),cout<<"     ▏";
    if(a==0) SetPos(18,Xy),cout<<"  ┃",Color(What+10),cout<<"●",Color(5),cout<<"┃",SetPos(19,Xy),cout<<"  ╰┳╯",SetPos(20,Xy),cout<<"     ▏";
    if(a==1) SetPos(18,Xy),cout<<"  ",Color(What+10),cout<<"●",Color(5),cout<<"  ┃",SetPos(19,Xy),cout<<"  ╰┳╯",SetPos(20,Xy),cout<<"     ▏";
    if(a==2) SetPos(18,Xy),Color(What+10),cout<<"●",Color(5),cout<<"┃  ┃",SetPos(19,Xy),cout<<"  ╰┳╯",SetPos(20,Xy),cout<<"     ▏";
    if(a==3) SetPos(18,Xy),cout<<"  ┃  ┃",SetPos(19,Xy),Color(What+10),cout<<"●",Color(5),cout<<"╰┳╯",SetPos(20,Xy),cout<<"     ▏";
    if(a==4) SetPos(18,Xy),cout<<"  ┃  ┃",SetPos(19,Xy),cout<<"  ╰┳╯",SetPos(20,Xy),Color(What+10),cout<<"●",Color(5),cout<<"   ▏";
    if(a==5) SetPos(18,Xy),cout<<"  ┃  ┃",SetPos(19,Xy),cout<<"  ╰┳╯",SetPos(20,Xy),cout<<"  ",Color(What+10),cout<<"●",Color(5),cout<<" ▏";
    if(a==6) SetPos(18,Xy),cout<<"  ┃  ┃",SetPos(19,Xy),cout<<"  ╰┳╯",SetPos(20,Xy),cout<<"    ",Color(What+10),cout<<"●",Color(5),cout<<" ";
    Color(0);
}
void Start()
{
    char g;Color(5);system("cls");
    SetPos(1,1);cout<<"------- 愤 怒 的 小 鸟 -------";Color(0);
    SetPos(3,1);cout<<"空格瞄准,按X触发小鸟技能,←→移动弹弓";
    SetPos(5,1);cout<<"猪猪技能自动触发,空中会有墙出现。";
    SetPos(7,1);cout<<"危险值由命中率,猪的存活时间计算!";
    SetPos(9,1);cout<<"危险值点满后失败!1500分通关!";
    SetPos(1,20);cout<<"-------- 小 鸟 技 能 --------";
    SetPos(3,20);Color(11),cout<<"●",Color(0),cout<<":无技能";
    SetPos(5,20);Color(12),cout<<"●",Color(0),cout<<":分身!不同分身初速度大小相同,";
    SetPos(6,20);cout<<"        方向不同。";
    SetPos(7,20);Color(13),cout<<"●",Color(0),cout<<":加速!以当前速度做匀速直线运动,";
    SetPos(8,20);cout<<"          且免疫狙击猪的冲击。";
    SetPos(9,20);Color(14),cout<<"●",Color(0),cout<<":投蛋!并获得向上速度做匀速直线";
    SetPos(10,20);cout<<"          运动,快达可以穿墙。";
    SetPos(11,20);Color(15),cout<<"●",Color(0),cout<<":爆炸!";
    SetPos(13,20);Color(16),cout<<"●",Color(0),cout<<":回旋!开始做向左加速运动!发射";
    SetPos(14,20);cout<<"          时获得双倍水平速度。";
    SetPos(15,20);Color(17),cout<<"●",Color(0),cout<<":[被动] 弹跳力为普通鸟三倍。发射";
    SetPos(16,20);cout<<"          时获得1.5倍水平、竖直速度。";
    SetPos(11,1);cout<<"-------- 猪 猪 技 能 --------";
    SetPos(13,2);Color(2),cout<<"●",Color(0),cout<<":无技能";
    SetPos(14,1);Color(8),cout<<"▁▅";
    SetPos(15,2);Color(2),cout<<"●",Color(0),cout<<":防御力为普通猪三倍";
    SetPos(16,2);cout<<"○";
    SetPos(17,2);cout<<"│:做空中简谐运动,受死范围";
    SetPos(18,2);Color(2),cout<<"●",Color(0),cout<<"  为普通猪两倍。";
    SetPos(19,2);cout<<"    有几率跳起或发射冲击波,冲";
    SetPos(20,1);Color(2),cout<<"﹃●",Color(0),cout<<":开小鸟与同类,可以引爆TNT!";
    SetPos(18,20);Color(5),cout<<"按 y 开始游戏!";
    A:if(kbhit()) g=_getch();
    if(g!='y') goto A;
}
int main()
{
    system("mode con cols=79 lines=22");
    CONSOLE_CURSOR_INFO cursor_info={1,0};
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
    srand((unsigned)time(NULL));St:Start();system("cls");
    memset(blt,0,sizeof(blt));memset(pig,0,sizeof(pig));
    memset(boo,0,sizeof(boo));memset(m,0,sizeof(m));
    T=put=K=K2=Sle=What=Pig=Sco=0;pigk=scok=-1;
    Xy=4,yX=18,yY=6;Blt=20,Bot=20,Pit=60;Color(7);
    SetPos(19,14);cout<<"■";
    SetPos(20,13);cout<<" █▍";m[19][14]=m[20][13]=m[20][14]=1;
    SetPos(21,0);for(int i=0;i<39;i++) cout<<"■",m[21][i]=1;
    Color(0);What=rand()%5+1;
    while(1)
    {
        if(Sco>=1500) break;
        T++;K=0;Color(0);
        if(Sco!=scok) SetPos(1,1),cout<<"分数:"<<Sco<<' ';
        if(Pig!=pigk){SetPos(3,1);cout<<"危险值:";int aa=min(Sco/100,10);Pig+=aa;
        SetPos(3,5);if(Pig<=2) Color(2);else if(Pig<=4) Color(16);else if(Pig<=6) Color(7);else if(Pig<=9) Color(6);
        else if(Pig<=12) Color(3);else if(Pig<=15) Color(17);else Color(11);
        for(int i=1;i<=Pig;i++) cout<<"■";Color(0);cout<<' '<<Pig;for(int i=1;i<=5;i++) cout<<"  ";
        if(Pig>18) break;Pig-=aa;}
        scok=Sco;pigk=Pig;
        if(GetAsyncKeyState(VK_LEFT)&0x8000&&Xy>0) Move(-2),Xy--,K=1;
        if(GetAsyncKeyState(VK_RIGHT)&0x8000&&Xy<10) Move(-2),Xy++,K=1;
        if(K==1)
        {
            if(put==0&&Sle==0) Move(0);
            else Move(-1);
        }
        if(kbhit())
        {
            char g=_getch();
            if(g=='x'||g=='X')
            {
                for(int i=Blt-10;i<=Blt;i++)
                if(blt[i].go==0&&blt[i].boom==0&&blt[i].W!=1&&blt[i].W!=7)
                {
                    blt[i].boom=1;
                    if(blt[i].W==2)
                    {
                        Blt++;blt[Blt].W=2;blt[Blt].vy=blt[i].vy*1.2;blt[Blt].vx=blt[i].vx+1;
                        blt[Blt].ax=blt[i].ax;blt[Blt].X=blt[i].X;blt[Blt].Y=blt[i].Y;blt[Blt].boom=1;
                        Blt++;blt[Blt].W=2;blt[Blt].vy=blt[i].vy*0.7;blt[Blt].vx=blt[i].vx-1;
                        blt[Blt].ax=blt[i].ax;blt[Blt].X=blt[i].X;blt[Blt].Y=blt[i].Y;blt[Blt].boom=1;
                    }
                    if(blt[i].W==3) blt[i].vy=fmax(blt[i].vy*1.5,2.5),blt[Blt].vx+=1,blt[i].ax=0;
                    if(blt[i].W==4)
                    {
                        blt[i].vx=-3;blt[i].ax=0.1;Blt++;blt[Blt].boom=1;blt[Blt].W=10;
                        blt[Blt].X=blt[i].X;blt[Blt].Y=blt[i].Y;blt[Blt].ax=blt[i].ax,blt[Blt].vx=1;
                    }
                    if(blt[i].W==5) Bot++,boo[Bot].X=blt[i].X,boo[Bot].Y=blt[i].Y,boo[Bot].S=1,boo[Bot].mS=5,blt[i].go=1;
                    if(blt[i].W==6) blt[i].ay=-1,blt[i].ax=0.3,blt[i].vx=min(blt[i].vx/2,(float)0);
                    break;
                }
            }
        }
        if(GetAsyncKeyState(' ')&0x8000&&K==0&&Sle==0)
        {
            if(put<=5) Move(1),yX=18,yY=Xy+1;
            else if(put<=20) Move(2),yX=18,yY=Xy;
            else if(put<=40) Move(3),yX=19,yY=Xy;
            else if(put<=60) Move(4),yX=20,yY=Xy;
            else if(put<=80) Move(5),yX=20,yY=Xy+1;
            else Move(6),yX=20,yY=Xy+2;
            if(put==0) K2=1;if(put==90) K2=-1;
            if(K2==1) put+=min(rand()%7+1,90-put);
            if(K2==-1) put-=min(rand()%7+1,put);
            Cout(1,17,Xy+2);
        }
        if((!(GetAsyncKeyState(' ')&0x8000)&&(put!=0))||(put!=0&&K==1))
        Move(-1),Creat(1,put),put=0,yX=18,yY=5,Sle=1,What=rand()%7+1,Creat(-1,-1),Sco=max(Sco-5,0);
        for(int i=Blt-10;i<=Blt;i++) if(blt[i].go==0) Go(i);
        for(int i=Bot-10;i<=Bot;i++) if(boo[i].go==0) Boom(i),Cout(2,0,0);
        for(int i=Pit-50;i<=Pit;i++) if(pig[i].go==0) Kill(i);
        if(Sle!=0) Move(-1);
        else if(put==0) Move(0);
        if(T%300==0) system("cls"),pigk=scok=-1;
        if(T%100==0)
        {
            Color(7);
            for(int i=0;i<=18;i++)
            for(int j=0;j<=40;j++) if(m[i][j]==1&&T%100==0) SetPos(i,j),cout<<"■";
            SetPos(19,14),cout<<"■",SetPos(20,13),cout<<" █▍";
            SetPos(21,0);for(int i=0;i<39;i++) cout<<"■";Color(0);
        }
        if(T%min(50,(2000-Sco)/30)==0) Pig++,Creat(0,-1);
        Sleep(30);
    }
    if(Sco<1500) {SetPos(9,17);system("color 7F");Color(11);cout<<"YOU DIE !";}
    else {SetPos(9,17);system("color 6E");Color(5);cout<<"YOU WIN !";}
    SetPos(11,16);Sleep(1000);cout<<"play again? (y/n)";Sleep(1000);char g;
    A:if(kbhit()) g=_getch();SetPos(18,0);
    if(g=='n') return 0;
    else if(g!='y') goto A;
    else if(g=='y') goto St;
}