• 个人简介

    yc:孙洋 生僻字 我们OI的算法

    纷乱复杂变化

    凝聚时代精华

    谱成一代神话

    我们竞赛的故事

    一点一滴汇集成诗

    有向图上跑跑最短路

    仙人掌上烤着面包

    增广路 最小割 最大流

    数论 群论 线代 函数

    半平面交

    二维凸包

    旋转卡壳 疯狂

    简单模拟 交叉模拟 字符处理 贪心暴力

    概率期望 后缀数组 线性递推 矩阵求逆

    莫比乌斯 拉格朗日 高斯消元 欧拉定理

    递推 递归 数论 博弈

    倍增 排序 莫队 分块

    树链剖分 可持久化 状态压缩 线性规划

    单调决策 动态规划 单调队列 斜率优化

    随手拍个平衡树

    代码千行挥洒

    常数实在太大

    运行时间爆炸

    怀念那些多项式

    乘除取模求逆差值

    考前总是会迷茫

    闲来充点智商

    巨佬咕值太高我心里正发慌

    想当年比赛几场

    暴力卡常从容风光

    愤怒(的)小鸟 飞翔(的)小鸟 寻找道路 铺设道路

    货车运输 信息传递 联合权值 玩具谜题

    双栈排序 国王游戏 观光公交 开车旅行

    奶酪 子串 (斗)地主 蚯蚓

    (逛)公园 宝藏 列队 旅行

    靶形数独 天天(爱)跑步 疫情控制 引水入城

    运输计划 赛道修建 填数游戏 保卫王国

    我们复赛的考试

    从来没有考纲

    偶尔出个原题

    你却都不认识

    一直梦想上大学

    停课半年没有省四

    现在全国各OJ

    到处有大神犇

    你谷的用户天天AK IOI

    像我吊打集训队

    也要拼搏才能无悔

    考试爆零我们都经历过

    拾起文化课从零开始生活 (艹皿艹 ) 我的头文件:

    #include <queue>
    #include <math.h>
    #include <stack>
    #include <vector>
    #include <stdio.h>
    #include <iostream>
    #include <vector>
    #include <iomanip>
    #include <string.h>
    #include<cstring>
    #include <algorithm>
    #define LL long long
    const int N = 1e5 + 10;
    const int INF = 0x3f3f3f3f;
    using namespace std;
    
    int main()
    {
    
    	return 0;
    }
    
    #include <algorithm>   
    #include <bitset>     
    #include <cctype>
    #include <cerrno>
    #include <clocale>
    #include <cmath>
    #include <complex>    
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <ctime>
    #include <deque>     
    #include <exception>   
    #include <fstream>
    #include <functional>   
    #include <limits>
    #include <list>      
    #include <map>      
    #include <iomanip>
    #include <ios>      
    #include <iosfwd>     
    #include <iostream>
    #include <istream>    
    #include <ostream>    
    #include <queue>     
    #include <set>      
    #include <sstream>    
    #include <stack>      
    #include <stdexcept>   
    #include <streambuf>   
    #include <string>     
    #include <utility>    
    #include <vector>     
    #include <cwchar>
    #include <cwctype>
    
    //windows头文件
    #include <complex.h>  
    #include <fenv.h>    
    #include <inttypes.h>  
    #include <stdbool.h>  
    #include <stdint.h>   
    #include <tgmath.h>
    #include <windows.h>
    

    MC:

    #include <iostream>
    #include <conio.h>
    #include <string>
    #include <map>
    #include <cmath>
    #include <windows.h>
    #include <time.h> 
    #define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
    using namespace std;
    int fallspeed;
    int jumpspeed = -3;
    int gravity = 1;
    int y = 400, x = 500;
    int restartposy, restartposx, face, health = 1000, lasthealth = 1000, breath = 100, hungry = 1000, dienum;
    bool attack, defense, hurt, mode;
    struct TNT
    {
    	int y;
    	int x;
    	int time;
    	bool issave;
    };
    struct BLOCK
    {
    	int color;
    	string ch;
    	string type;
    };
    struct MOB
    {
    	int fallspeed;
    	int health;
    	bool hurt;
    	int y;
    	int x;
    	int attack;
    	string shap;
    	bool isenemy;
    	int color;
    	string name;
    };
    struct ARROW
    {
    	string shap;
    	double y;
    	double x;
    	double fallspeed;
    	double plusx;
    };
    TNT tnt[20];
    string die;
    ARROW arrow[100];
    MOB mobs[50] = {
    	{0,1000,0,0,0,100,"危",true,7,"危"},
    	{0,10,0,0,0,10,"  ",true,7,"  "},
    	{0,1000,0,0,0,100,"MM",false,7,"MM"},
    	{0,100000,0,90,70,-100,"AC",true,7,"Accept"},
    	{0,10000,0,90,70,500,"BO",true,7,"BOSS"},
    	{0,100000,0,90,70,-1000,"AK",true,7,"AK"},
    };
    MOB mob[100] = {
    	{0,1000,0,92,4,100,"WA",true,7,"Wrong Anwser"},
    	{0,1000,0,92,4,100,"TL",true,7,"Time Limit Error"},
    	{0,2000,0,92,4,300,"CE",true,7,"Compile Error"},
    	{0,1000,0,45,9,100,"WA",true,7,"Wrong Anwser"},
    	{0,100000,0,90,70,-100,"AC",true,7,"Accept"},
    	{0,100000,0,90,70,-1000,"AK",true,7,"AK"},
    	{0,10000,0,90,70,500,"UK",true,7,"Unknown Error"},
    	{0,1000,0,92,3,0,"MM",false,7,"MM"},
    	{0,1000,0,92,3,0,"MM",false,7,"MM"},
    	{0,1000,0,90,15,0,"MM",false,7,"MM"},
    	{0,1000,0,90,80,0,"MM",false,7,"MM"},
    };
    BLOCK block[32] = {
    	{0,"  ","air"},//空气
    	{6,"██","block"},//土块
    	{8,"██","block"},//石头
    	{2,"██","block"},//草方块
    	{15,"██","block"},//雪块 
    	{4,"██","block"},//岩浆块
    	{14,"▓▓","fallblock"},//沙块 
    	{8,"II","fallblock"},//铁砧
    	{9,"██","water"},//水
    	{9,"▇▇","water"},//水
    	{9,"▆▆","water"},//水
    	{9,"▅▅","water"},//水
    	{9,"▄▄","water"},//水
    	{9,"▃▃","water"},//水
    	{9,"▂▂","water"},//水
    	{9,"▁▁","water"},//水
    	{12,"██","lava"},//岩浆
    	{12,"▇▇","lava"},//岩浆
    	{12,"▆▆","lava"},//岩浆
    	{12,"▅▅","lava"},//岩浆
    	{12,"▄▄","lava"},//岩浆
    	{12,"▃▃","lava"},//岩浆
    	{12,"▂▂","lava"},//岩浆
    	{12,"▁▁","lava"},//岩浆  
    	{12,"危","background"},//危
    	{6,"██","background"},//木头
    	{10,"▓▓","background"},//树叶 
    	{15,"▓▓","background"},//带雪树叶
    	{15,"▅▅","bomb"},//TNT爆炸 
    	{12,"Ⅲ","TNT"},//TNT
    	{7,"Ⅲ","TNT"},//TNT2
    	{6,"∷","ladder"},//梯子
    };
    int board[1005][1005];
    int setboard[1005][1005];
    int bag[100];
    int clear_buffer()
    {
    	while(kbhit())
    	{
    		if(getch() != EOF); 
    		for(int i = 1; i <= 256; i++)
    		{
    			if(GetAsyncKeyState(i));
    		}
    	}
    	return 0;
    }
    void color(int a)
    {
    	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
    /*	1	深蓝色
    	2	深绿色
    	3	深青色 
    	4	深红色
    	5	深粉色
    	i	黄色
    	7	深白色
    	8	灰色
    	9	浅蓝色
    	10	浅绿色 
    	11	浅青色 
    	12	浅红色 
    	13	浅粉色 
    	14	浅黄色 
    	15	浅白色 
    	背景
    	1~15		黑色 
    	16~31		深蓝色 
    	32~47		深绿色
    	48~63		深青色
    	64~79		深红色
    	'S'~95		深粉色
    	96~111		深黄色
    	112~127 	深白色
    	128~143 	灰色
    	144~159 	浅蓝色
    	160~1'A' 	浅绿色
    	176~191 	浅青色
    	192~207 	浅红色
    	208~223 	浅粉色
    	224~239 	浅黄色
    	240~255 	浅白色
    */
    }
    int init()//听说有人要我增加地图生成的注释,所以我就写了。 
    {
    	for(int j = 0; j < 100; j++)
    	{
    		bag[j] = 0;//这个...初始化背包 
    	}
    	for(int i = 0; i < 1000; i++)
    	{
    		for(int j = 0; j < 1000; j++)
    		{
    			board[i][j] = 0;//初始化地图 (我们的y是倒着来的) 
    		}
    	} 
    	double lasty = rand() % 101 + 400;//lasty代表上一个我们选择的点的高度。 
    	for(int i = 5; i < 1000; i += 5)//i每次加5,每隔5个点连一条线 
    	{
    		double y = rand() % 21 - 10 + lasty;//y代表这个点我们选择的高度,为了不出现太陡峭的山,我们只允许这个高度在刚才的点的高低10格内。 
    		y = min(450.0, y);//这是最小高度,防止整个地图都在水里。 
    		double high = lasty;//这个high是用来统计当前高度的,用double可以更加精确。
    		int dirt = rand() % 5 + 2;//dirt代表这一列上泥土高度。 
    		for(int j = i - 5; j < i; j++)
    		{
    			high += (y - lasty) / 5;//high每次增加差距的1/5。 
    			for(int k = 999; k >= (int)high; k--)
    			{
    				if(k == (int)high)//如果是最高点 
    				{
    					setboard[k][j] = 3;//就用草地 
    					if(high <= 350)//如果high比较高 
    					{
    						setboard[k][j] = 4;//就用雪地 
    					}
    				}
    				else if(k - dirt <= (int)high)//泥土 
    				{
    					setboard[k][j] = 1;
    				}
    				else 
    				{
    					setboard[k][j] = 2;//石头 
    				}
    			}
    		}
    		lasty = y;//赋值 
    	}
    	//再来一边,填满最后几格 
    	int dirt = rand() % 5 + 2;
    	double high = lasty;
    	for(int j = 995; j < 999; j++)
    	{
    		for(int k = 999; k >= (int)high; k--)
    		{
    			if(k == (int)high)
    			{
    				setboard[k][j] = 3;
    				if(high <= 350)
    				{
    					setboard[k][j] = 4;
    				}
    			}
    			else if(k - dirt <= (int)high)
    			{
    				setboard[k][j] = 1;
    			}
    			else 
    			{
    				setboard[k][j] = 2;
    			}
    		}
    	}
    	//填满水,这里默认把海平面高度设为410。 
    	for(int i = 0; i < 1000; i++)
    	{
    		for(int j = 600; j >= 410; j--)
    		{
    			if(setboard[j][i] == 0)
    			{
    				setboard[j][i] = 8;
    			}
    		}
    	}
    	//沙子 
    	for(int i = 0; i < 1000; i++)
    	{
    		bool a = 0;
    		for(int j = 999; j >= 0; j--)
    		{
    			if(a && setboard[j][i] != 0  && setboard[j][i] != 8)
    			{
    				setboard[j][i] = 6;
    				continue;
    			}
    			if(setboard[j][i] == 8)
    			{
    				continue;
    			}
    			if(setboard[j][i + 3] == 8)
    			{
    				a = true;
    				setboard[j][i] = 6;
    			}
    			if(setboard[j][i + 2] == 8)
    			{
    				a = true;
    				setboard[j][i] = 6;
    			}
    			if(setboard[j][i + 1] == 8)
    			{
    				a = true;
    				setboard[j][i] = 6;
    			}
    			if(setboard[j][i - 1] == 8)
    			{
    				a = true;
    				setboard[j][i] = 6;
    			}
    			if(setboard[j][i - 2] == 8)
    			{
    				a = true;
    				setboard[j][i] = 6;
    			}
    			if(setboard[j][i - 3] == 8)
    			{
    				a = true;
    				setboard[j][i] = 6;
    			}
    			if(setboard[j - 2][i] == 8)
    			{
    				a = true;
    				setboard[j][i] = 6;
    			}
    			if(setboard[j - 1][i] == 8)
    			{
    				a = true;
    				setboard[j][i] = 6;
    			}
    			if(setboard[j - 3][i] == 8)
    			{
    				a = true;
    				setboard[j][i] = 6;
    			}
    			if(setboard[j - 4][i] == 8)
    			{
    				a = true;
    				setboard[j][i] = 6;
    			}
    		}
    	}
    	//树 
    	for(int i = 0; i < 1000; i++)
    	{
    		for(int j = 0; j < 1000; j++)
    		{
    			if(setboard[j][i] == 0 && block[setboard[j + 1][i]].type == "block")
    			{
    				if(rand() % 10 == 1)
    				{
    					setboard[j][i] = 25;
    					setboard[j - 1][i] = 25;
    					setboard[j - 2][i] = 25;
    					setboard[j - 3][i] = 25;
    					setboard[j - 3][i + 1] = 26;
    					setboard[j - 3][i - 1] = 26;
    					setboard[j - 4][i + 2] = 26; 
    					setboard[j - 4][i + 1] = 26;
    					setboard[j - 4][i] = 26;
    					setboard[j - 4][i - 1] = 26;
    					setboard[j - 4][i - 2] = 26;
    					setboard[j - 5][i + 2] = 26;
    					setboard[j - 5][i + 1] = 26;
    					setboard[j - 5][i] = 26;
    					setboard[j - 5][i - 1] = 26;
    					setboard[j - 5][i - 2] = 26;
    					setboard[j - 6][i + 1] = 26;
    					setboard[j - 6][i] = 26;
    					setboard[j - 6][i - 1] = 26;
    					if(j <= 350)
    					{
    						setboard[j - 3][i + 1] = 27;
    						setboard[j - 3][i - 1] = 27;
    						setboard[j - 4][i + 2] = 27; 
    						setboard[j - 4][i + 1] = 27;
    						setboard[j - 4][i] = 27;
    						setboard[j - 4][i - 1] = 27;
    						setboard[j - 4][i - 2] = 27;
    						setboard[j - 5][i + 2] = 27;
    						setboard[j - 5][i + 1] = 27;
    						setboard[j - 5][i] = 27;
    						setboard[j - 5][i - 1] = 27;
    						setboard[j - 5][i - 2] = 27;
    						setboard[j - 6][i + 1] = 27;
    						setboard[j - 6][i] = 27;
    						setboard[j - 6][i - 1] = 27;
    					}
    				}
    			}
    		}
    	} 
    	//地洞 
    	for(int j = 999; j >= 700; j--)
    	{
    		if(rand() % 10 == 1)
    		{
    			setboard[j - 3][2] = 0;
    			setboard[j - 2][2] = 0; setboard[j - 2][3] = 0;
    			setboard[j - 1][2] = 0; setboard[j - 1][3] = 0; setboard[j - 1][4] = 0;
    			setboard[j][2] = 0; setboard[j][3] = 0; setboard[j][4] = 0; setboard[j][5] = 0;
    			setboard[j + 1][2] = 0; setboard[j + 1][3] = 0; setboard[j + 1][4] = 0;
    			setboard[j + 2][2] = 0; setboard[j + 2][3] = 0;
    			setboard[j + 3][2] = 0;
    		}
    	}
    	for(int i = 3; i < 997; i++)
    	{
    		for(int j = 996; j >= 500; j--)
    		{
    			if(block[setboard[j + 3][i]].type == "block" && block[setboard[j - 3][i]].type == "block" && setboard[j][i] == 0 && setboard[j + 1][i] == 0 && setboard[j + 2][i] == 0 && setboard[j - 1][i] == 0  && setboard[j - 2][i] == 0)
    			{
    				j += rand() % 5 - 2;
    				j = max(3, j);
    				j = min(996, j);
    				if(rand() % 500 <= 499)
    				{
    					setboard[j - 3][i] = 0;
    					setboard[j - 2][i - 1] = 0; setboard[j - 2][i] = 0; setboard[j - 2][i + 1] = 0;
    					setboard[j - 1][i - 2] = 0; setboard[j - 1][i - 1] = 0; setboard[j - 1][i] = 0; setboard[j - 1][i + 1] = 0; setboard[j - 1][i + 2] = 0;
    					setboard[j][i - 3] = 0; setboard[j][i - 2] = 0; setboard[j][i - 1] = 0; setboard[j][i] = 0; setboard[j][i + 1] = 0; setboard[j][i + 2] = 0; setboard[j][i + 3] = 0;
    					setboard[j + 1][i - 2] = 0; setboard[j + 1][i - 1] = 0; setboard[j + 1][i] = 0; setboard[j + 1][i + 1] = 0; setboard[j + 1][i + 2] = 0;
    					setboard[j + 2][i - 1] = 0; setboard[j + 2][i] = 0; setboard[j + 2][i + 1] = 0;
    					setboard[j + 3][i] = 0;
    					if(rand() % 20 == 1)
    					{
    						for(int k = 0; k < 100; k++)
    						{
    							if(mob[k].shap == "")
    							{
    								mob[k] = {0,1000,0,0,0,100,"SS",true,7,"僵尸"};
    								mob[k].x = i;
    								mob[k].y = j;
    								break;
    							}
    						}
    					}
    				}
    			}
    			else if(block[setboard[j + 3][i]].type == "block" && block[setboard[j + 2][i]].type == "block" && block[setboard[j + 1][i]].type == "block" && block[setboard[j][i]].type == "block" && block[setboard[j - 1][i]].type == "block" && block[setboard[j - 2][i]].type == "block" && block[setboard[j - 3][i]].type == "block")
    			{
    				if(rand() % 500 == 1)
    				{
    					setboard[j - 3][i] = 0;
    					setboard[j - 2][i - 1] = 0; setboard[j - 2][i] = 0; setboard[j - 2][i + 1] = 0;
    					setboard[j - 1][i - 2] = 0; setboard[j - 1][i - 1] = 0; setboard[j - 1][i] = 0; setboard[j - 1][i + 1] = 0; setboard[j - 1][i + 2] = 0;
    					setboard[j][i - 3] = 0; setboard[j][i - 2] = 0; setboard[j][i - 1] = 0; setboard[j][i] = 0; setboard[j][i + 1] = 0; setboard[j][i + 2] = 0; setboard[j][i + 3] = 0;
    					setboard[j + 1][i - 2] = 0; setboard[j + 1][i - 1] = 0; setboard[j + 1][i] = 0; setboard[j + 1][i + 1] = 0; setboard[j + 1][i + 2] = 0;
    					setboard[j + 2][i - 1] = 0; setboard[j + 2][i] = 0; setboard[j + 2][i + 1] = 0;
    					setboard[j + 3][i] = 0;
    				}
    			}
    		}
    	}
    	//出生点 
    	bool a = false;
    	for(int i = 400; i < 1000; i++)
    	{
    		for(int j = 0; j < 1000; j++)
    		{
    			if(setboard[j][i] == 0 && block[setboard[j + 1][i]].type == "block" && (setboard[j + 1][i] == 3 || setboard[j + 1][i] == 4))
    			{
    				restartposy = j;
    				restartposx = i;
    				y = j;
    				x = i;
    				a = true;
    				break;
    			}
    		}
    		if(a)
    		{
    			break;
    		}
    	}
    	return 0;
    }
    int Arrowmove()
    {
    	for(int i = 0; i < 100; i++)
    	{
    		if(arrow[i].shap == "")
    		{
    			continue;
    		}
    		arrow[i].x += (int)arrow[i].plusx;
    		arrow[i].plusx -= 0.1;
    		for(int j = (int)arrow[j].y + 1; j <= (int)arrow[j].y + (int)arrow[j].fallspeed; j++)
    		{
    			if(block[board[j][(int)arrow[j].x]].type == "block" || block[board[j][(int)arrow[j].x]].type == "fallblock")
    			{
    				arrow[i].fallspeed = 0;
    				return 0;
    			}
    		}
    		arrow[i].y += arrow[i].fallspeed;
    		arrow[i].fallspeed += 0.1;
    		if(arrow[i].y > 999)
    		{
    			arrow[i].shap = "";
    		}
    		if(block[board[(int)arrow[i].y + 1][(int)arrow[i].x]].type == "block" || block[board[(int)arrow[i].y + 1][(int)arrow[i].x]].type == "fallblock")
    		{
    			arrow[i].shap = "";
    		}
    	}
    	return 0;
    }
    int mobmove()
    {
    	for(int j = 0; j < 100; j++)
    	{
    		if(mob[j].shap == "")
    		{
    			continue;
    		}
    		mob[j].hurt = false;
    		mob[j].color = 7;
    		if(mob[j].health <= 0 || mob[j].y > 999)
    		{
    			mob[j].shap = "";
    			mob[j].color = 7;
    			continue;
    		}
    		if(block[board[mob[j].y][mob[j].x]].type == "lava")
    		{
    			mob[j].health -= 200;
    			mob[j].hurt = true;
    		}
    		else if((board[mob[j].y + 1][mob[j].x] == 5) || ((mob[j].y == y || mob[j].y == y - 1) && (mob[j].x == x + 1 || mob[j].x == x || mob[j].x == x - 1) && KEY_DOWN(' ')))
    		{
    			mob[j].health -= 100;
    			mob[j].hurt = true;
    		}
    		if(mob[j].y == y && mob[j].x == x && mob[j].isenemy)
    		{
    			health -= mob[j].attack;
    			hurt = true;
    			die = "被 " + mob[j].name + " 杀死了";
    		}
    		for(int i = mob[j].y - 1; i >= mob[j].y + mob[j].fallspeed; i--)
    		{
    			if(block[board[i - 1][mob[j].x]].type == "block")
    			{
    				mob[j].fallspeed = 0 - mob[j].y + i + 1;
    				return 0;
    			}
    		}
    		for(int i = mob[j].y + 1; i <= mob[j].y + mob[j].fallspeed; i++)
    		{
    			if(block[board[i][mob[j].x]].type == "block" || block[board[i][mob[j].x]].type == "fallblock")
    			{
    				if(mob[j].fallspeed >= 5 && block[board[i - 1][mob[j].x]].type == "water")
    				{
    					mob[j].health -= 50 * (mob[j].fallspeed - 4);
    					mob[j].hurt = true;
    				}
    				mob[j].fallspeed = 0;
    				return 0;
    			}
    		}
    		mob[j].y += mob[j].fallspeed;
    		mob[j].fallspeed += gravity;
    		if(mob[j].isenemy)
    		{
    			if(mob[j].y > y && (block[board[mob[j].y + 1][mob[j].x]].type == "block" || block[board[mob[j].y + 1][mob[j].x]].type == "fallblock"))
    			{
    				if(mob[j].y > y + 50)
    				{
    					mob[j].fallspeed = -7;
    				}
    				mob[j].fallspeed = -3;
    			}
    			if(mob[j].x < x)
    			{
    				if(block[board[mob[j].y][mob[j].x + 1]].type != "block" || block[board[mob[j].y][mob[j].x + 1]].type != "fallblock")
    				{
    					mob[j].x++;
    				}
    				else if(block[board[mob[j].y + 1][mob[j].x]].type == "block" || block[board[mob[j].y + 1][mob[j].x]].type != "fallblock")
    				{
    					mob[j].fallspeed = -3;
    				}
    			}
    			else if(mob[j].x > x)
    			{
    				if(block[board[mob[j].y][mob[j].x - 1]].type != "block" || block[board[mob[j].y][mob[j].x - 1]].type != "fallblock")
    				{
    					mob[j].x--;
    				}
    				else if(block[board[mob[j].y + 1][mob[j].x]].type == "block" || block[board[mob[j].y + 1][mob[j].x]].type != "fallblock")
    				{
    					mob[j].fallspeed = -3;
    				}
    			}
    		}
    		else
    		{
    			if(rand() % 3 == 0)
    			{
    				if(block[board[mob[j].y][mob[j].x + 1]].type != "block" || block[board[mob[j].y][mob[j].x + 1]].type != "fallblock")
    				{
    					mob[j].x++;
    				}
    				else if(block[board[mob[j].y + 1][mob[j].x]].type == "block" || block[board[mob[j].y + 1][mob[j].x]].type != "fallblock")
    				{
    					mob[j].fallspeed = -3;
    				}
    			}
    			else if(rand() % 3 == 1)
    			{
    				if(block[board[mob[j].y][mob[j].x - 1]].type != "block" || block[board[mob[j].y][mob[j].x - 1]].type != "fallblock")
    				{
    					mob[j].x--;
    				}
    				else if(block[board[mob[j].y + 1][mob[j].x]].type == "block" || block[board[mob[j].y + 1][mob[j].x]].type != "fallblock")
    				{
    					mob[j].fallspeed = -3;
    				}
    			}
    		}
    		if(mob[j].hurt)
    		{
    			mob[j].color = 12;
    		}
    	}
    	return 0;
    }
    int print()
    {
    	if(!mode)
    	{
    		color(8);
    		cout << "HP:";
    		color(12);
    		cout << health << endl; 
    		for(int i = 0; i < health; i += 100)
    		{
    			cout << "◆";
    		}
    		color(7);
    		for(int i = health; i < lasthealth; i += 100)
    		{
    			cout << "◇";
    		}
    		cout << endl;
    		color(8);
    		cout << "AIR:";
    		color(11);
    		cout << breath << endl;
    		for(int i = 0; i < breath; i += 10)
    		{
    			cout << "●";
    		}
    		for(int i = breath; i < 91; i += 10)
    		{
    			cout << "○";
    		}
    		cout << endl;
    		color(8);
    		cout << "HUNGRY:";
    		color(14);
    		cout << hungry << endl;
    		for(int i = 0; i < hungry; i += 100)
    		{
    			cout << "§";
    		}
    		cout << endl;
    	} 
    	color(8);
    	cout << "DIENUM:";
    	color(4);
    	cout << dienum << endl;
    	for(int i = y - 6; i <= y + 6; i++)
    	{
    		for(int j = x - 6; j <= x + 6; j++)
    		{
    			bool ismob = false;
    			for(int s = 0; s < 100; s++)
    			{
    				if(mob[s].shap == "")
    				{
    					continue;
    				}
    				else if(mob[s].x == j && mob[s].y == i)
    				{
    					color(mob[s].color);
    					cout << mob[s].shap;
    					ismob = true;
    					break;
    				}
    			}
    			if(ismob)
    			{
    				continue;
    			}
    			for(int s = 0; s < 100; s++)
    			{
    				if(arrow[s].shap == "")
    				{
    					continue;
    				}
    				else if((int)arrow[s].x == j && (int)arrow[s].y == i)
    				{
    					color(7);
    					cout << arrow[s].shap;
    					ismob = true;
    					break;
    				}
    			}
    			if(ismob)
    			{
    				continue;
    			}
    			else if(i == y && j == x)
    			{
    				if (KEY_DOWN('S'))
    				{
    					color(14);
    					if(hurt)
    					{
    						color(12);
    					}
    					cout << "()";
    				}
    				else
    				{
    					color(9);
    					if(hurt)
    					{
    						color(12);
    					}
    					cout << "∏";
    				}
    			}
    			else if(i == y - 1 && j == x)
    			{
    				if (!KEY_DOWN('S'))
    				{
    					color(14);
    					if(hurt)
    					{
    						color(12);
    					}
    					cout << "()";
    				}
    				else
    				{
    					color(block[board[i][j]].color);
    					cout << block[board[i][j]].ch;
    				}
    			}
    			else
    			{
    				if(i < 0 || i >= 1000 || j < 0 || j >= 1000)
    				{
    					cout << "  ";
    					continue;
    				}
    				color(block[board[i][j]].color);
    				cout << block[board[i][j]].ch;
    			}
    		}
    		cout << endl;
    	}
    	color(7);
    	cout << "Y:";
    	color(6);
    	cout << 1000 - y << endl;
    	color(7);
    	cout << "X:";
    	color(6);
    	cout << x << endl;
    	return 0;
    }
    int move()
    {
    	if(board[y][x] == 31)
    	{
    		y += fallspeed;
    		return 0;
    	}
    	if(block[board[y][x]].type == "water")
    	{
    		if(fallspeed > 1)
    		{
    			fallspeed = 1;
    		}
    	}
    	else
    	{
    		for(int i = y - 1; i >= y + fallspeed; i--)
    		{
    			if(block[board[i - 1][x]].type == "block" || block[board[i - 1][x]].type == "fallblock")
    			{
    				fallspeed = 0 - y + i + 1;
    				return 0;
    			}
    		}
    	}
    	for(int i = y + 1; i <= y + fallspeed; i++)
    	{
    		if(block[board[i][x]].type == "block" || block[board[i][x]].type == "fallblock")
    		{
    			if(fallspeed >= 5 && block[board[i - 1][x]].type != "water")
    			{
    				health -= 50 * (fallspeed - 4);
    				if(fallspeed >= 7)
    				{
    					die = "落地过猛!";
    				}
    				else
    				{
    					die = "从高处摔了下来!";
    				}
    				hurt = true;
    			}
    			fallspeed = 0;
    			return 0;
    		}
    	}
    	y += fallspeed;
    	fallspeed += gravity;
    	return 0;
    }
    int bomb()
    {
    	for(int i = 0; i < 20; i++)
    	{
    		if(tnt[i].time == 0)
    		{
    			int atk = 0;
    			if(abs(x - tnt[i].x) + abs(y - tnt[i].y) == 4)
    			{
    				atk = 50;
    				fallspeed -= 1;
    				x += x - tnt[i].x;
    			}
    			if(abs(x - tnt[i].x) + abs(y - tnt[i].y) == 3)
    			{
    				atk = 100;
    				fallspeed -= 2;
    				x += x - tnt[i].x;
    			}
    			if(abs(x - tnt[i].x) + abs(y - tnt[i].y) == 2)
    			{
    				atk = 300;
    				fallspeed -= 4;
    				x += 2 * (x - tnt[i].x);
    			}
    			if(abs(x - tnt[i].x) + abs(y - tnt[i].y) == 1)
    			{
    				atk = 500;
    				fallspeed -= 7;
    				x += 5 * (x - tnt[i].x);
    			}
    			if(abs(x - tnt[i].x) + abs(y - tnt[i].y) == 0)
    			{
    				atk = 800;
    				fallspeed -= 10;
    			}
    			tnt[i].time--;
    			if(!tnt[i].issave)
    			{
    				health -= atk;
    			}
    			die = "被TNT炸死了";
    			if(atk > 0 && !tnt[i].issave)
    			{
    				hurt = true;
    			}
    			if(!tnt[i].issave)
    			{
    				for(int yy = tnt[i].y - 3; yy <= tnt[i].y + 3; yy++)
    				{
    					for(int xx = tnt[i].x - 3; xx <= tnt[i].x + 3; xx++)
    					{
    						if((int)(sqrt(abs(yy - tnt[i].y) * abs(yy - tnt[i].y) + abs(xx - tnt[i].x) * abs(xx - tnt[i].x)) + 0.9999) == 3)
    						{
    							setboard[yy][xx] = 28;
    						}
    						if((int)(sqrt(abs(yy - tnt[i].y) * abs(yy - tnt[i].y) + abs(xx - tnt[i].x) * abs(xx - tnt[i].x)) + 0.9999) < 3)
    						{
    							setboard[yy][xx] = 0;
    						}
    					}
    				}
    			}
    		}
    		else if(tnt[i].time == -1)
    		{
    			setboard[tnt[i].y][tnt[i].x] = 0;
    			if(!tnt[i].issave)
    			{
    				for(int yy = tnt[i].y - 3; yy <= tnt[i].y + 3; yy++)
    				{
    					for(int xx = tnt[i].x - 3; xx <= tnt[i].x + 3; xx++)
    					{
    						if((int)(sqrt(abs(yy - tnt[i].y) * abs(yy - tnt[i].y) + abs(xx - tnt[i].x) * abs(xx - tnt[i].x)) + 0.9999) <= 3)
    						{
    							setboard[yy][xx] = 0;
    						}
    					}
    				}
    			}
    			tnt[i].time--;
    		}
    		else if(tnt[i].time > 0)
    		{
    			tnt[i].time--;
    			if(tnt[i].time % 2 == 0)
    			{
    				setboard[tnt[i].y][tnt[i].x] = 29;
    			}
    			else
    			{
    				setboard[tnt[i].y][tnt[i].x] = 30;
    			}
    		}
    	}
    	return 0;
    }
    int check()
    {
    	for(int i = 0; i < 1000; i++)
    	{
    		for(int j = 0; j < 1000; j++)
    		{
    			if(block[board[i][j]].type == "water" && board[i][j] != 15)
    			{
    				if(board[i + 1][j] == 0)
    				{
    					setboard[i + 1][j] = board[i][j];
    					setboard[i + 1][j] = 8;
    				}
    				else if(block[board[i + 1][j]].type == "lava")
    				{
    					setboard[i + 1][j] = 2;
    				}
    				else if(block[board[i + 1][j]].type == "block" || block[board[i + 1][j]].type == "fallblock")
    				{
    					if(board[i][j + 1] == 0)
    					{
    						setboard[i][j + 1] = board[i][j] + 1;
    					}
    					else if(block[board[i][j + 1]].type == "lava")
    					{
    						setboard[i][j + 1] = 2;
    					}
    					if(board[i][j - 1] == 0)
    					{
    						setboard[i][j - 1] = board[i][j] + 1;
    					}
    					else if(block[board[i][j - 1]].type == "lava")
    					{
    						setboard[i][j - 1] = 2;
    					}
    				}
    			}
    			if(block[board[i][j]].type == "lava" && board[i][j] != 23)
    			{
    				if(board[i + 1][j] == 0)
    				{
    					setboard[i + 1][j] = board[i][j];
    					setboard[i + 1][j] = 16;
    				}
    				else if(block[board[i + 1][j]].type == "water")
    				{
    					setboard[i + 1][j] = 2;
    				}
    				else if(block[board[i + 1][j]].type == "block" || block[board[i + 1][j]].type == "fallblock")
    				{
    					if(board[i][j + 1] == 0)
    					{
    						setboard[i][j + 1] = board[i][j] + 1;
    					}
    					else if(block[board[i][j + 1]].type == "water")
    					{
    						setboard[i][j + 1] = 2;
    					}
    					if(board[i][j - 1] == 0)
    					{
    						setboard[i][j - 1] = board[i][j] + 1;
    					}
    					else if(block[board[i][j - 1]].type == "water")
    					{
    						setboard[i][j - 1] = 2;
    					}
    				}
    			}
    			if(block[board[i][j]].type == "fallblock")
    			{
    				if(board[i + 2][j] == 0 && board[i + 1][j] == 0 && i + 2 < 100)
    				{
    					setboard[i][j] = 0;
    					setboard[i + 2][j] = board[i][j];
    					if(board[i][j] == 7 && j == x && i + 2 == y)
    					{
    						health -= 600;
    						hurt = true;
    						die = "被压扁了";
    					}
    				}
    				else if(board[i + 1][j] == 0 && i + 1 < 100)
    				{
    					setboard[i][j] = 0;
    					setboard[i + 1][j] = board[i][j];
    					if(board[i][j] == 7 && j == x && i + 1 == y)
    					{
    						health -= 600;
    						hurt = true;
    						die = "被压扁了";
    					}
    					else if(board[i][j] == 7 && j == x && i + 2 == y)
    					{
    						health -= 600;
    						hurt = true;
    						die = "被压扁了";
    					}
    				}
    			}
    		}
    	}
    	for(int i = 0; i < 1000; i++)
    	{
    		for(int j = 0; j < 1000; j++)
    		{
    			board[i][j] = setboard[i][j];
    		}
    	}
    }
    int main()
    {
    	srand((int)time(0));
    	for(int i = 0; i < 20; i++)
    	{
    		tnt[i].time = -2;
    	}
    	init();
    	while(1)
    	{
    		system("cls");
    		if(!mode)
    		{
    			move();
    		} 
    		if(KEY_DOWN('F'))
    		{
    			setboard[y + 1][x] = 2;
    		}
    		check();
    		bomb();
    		Arrowmove();
    		mobmove();
    		if(mode)
    		{
    			hurt = false;
    		} 
    		print();
    		Sleep(30);
    		hungry--;
    		hungry = max(hungry, 0);
    		if(hungry == 0)
    		{
    			die = "被饿死了";
    			hurt = true;
    			health -= 10;
    		}
    		if(mode)
    		{
    			health = 1000;
    		}
    		if(health <= 0)
    		{
    			Sleep(500); 
    			system("cls");
    			color(12);
    			cout << "           GAME OVER           " << endl;
    			color(7);
    			cout << "   STEVE " << die << endl;
    			dienum++;
    			Sleep(2000);
    			x = restartposx;
    			y = restartposy;
    			health = 1000;
    			hungry = 1000;
    			breath = 100;
    			fallspeed = 0;
    		}
    		health += (hungry + 201) / 300; 
    		if(health > 1000)
    		{
    			health = 1000; 
    		} 
    		if(attack)
    		{
    			attack = 0;
    		}
    		if(defense)
    		{
    			defense = 0;
    		}
    		if(hurt)
    		{
    			hurt = false;
    			lasthealth = health;
    		}
    		if(block[board[y][x]].type == "water")
    		{
    			fallspeed = 1;
    			if(KEY_DOWN('W'))
    			{
    				fallspeed = -1;
    			}
    		}
    		if(block[board[y - 1][x]].type == "water")
    		{
    			die = "被水淹死了!"; 
    			breath--; 
    		}
    		else
    		{
    			breath++; 
    			if(breath > 100)
    			{
    				breath = 100; 
    			} 
    		} 
    		if(board[y][x] == 31)
    		{
    			fallspeed = 0;
    			if(KEY_DOWN('W'))
    			{
    				fallspeed = -1;
    			}
    			if(KEY_DOWN('S'))
    			{
    				fallspeed = 1;
    			}
    		}
    		if(block[board[y][x]].type == "lava")
    		{
    			fallspeed = 1;
    			if(KEY_DOWN('W'))
    			{
    				fallspeed = -1;
    			}
    			die = "试图在岩浆里游泳!"; 
    			hurt = true;
    			health -= 100; 
    		}
    		if (KEY_DOWN('W') && !KEY_DOWN('S'))
    		{
    			if(mode)
    			{
    				y--;
    			}
    			else
    			{
    				if(block[board[y][x]].type != "water" && board[y][x] != 31)
    				{
    					if(block[board[y + 1][x]].type == "block" || block[board[y + 1][x]].type == "fallblock")
    					{
    						fallspeed = jumpspeed;
    					}
    				}
    			}
    		}
    		if (KEY_DOWN('A'))
    		{
    			if((block[board[y][x - 1]].type != "block" && block[board[y][x - 1]].type != "fallblock") || mode)
    			{
    				if(KEY_DOWN('S') || (block[board[y - 1][x - 1]].type != "block" && block[board[y - 1][x - 1]].type != "fallblock") || mode)
    				{
    					x -= 1;
    				}
    			}
    			face = -1;
    		}
    		if (KEY_DOWN('D'))
    		{
    			if((block[board[y][x + 1]].type != "block" && block[board[y][x + 1]].type != "fallblock") || mode)
    			{
    				if(KEY_DOWN('S') || (block[board[y - 1][x + 1]].type != "block"  && block[board[y - 1][x + 1]].type != "fallblock") || mode)
    				{
    					x += 1;
    				}
    			}
    			face = 1;
    		}
    		if(KEY_DOWN('S'))
    		{
    			if(mode)
    			{
    				y++;
    			}
    			else
    			{
    				fallspeed += 1;
    			}
    		}
    		if(KEY_DOWN(' '))
    		{
    			attack = true;
    		}
    		if(KEY_DOWN('E'))
    		{
    			system("cls");
    			color(7);
    			cout << "┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐" << endl;
    			for(int i = 0; i < 9; i++)
    			{
    				color(7);
    				cout << "│";
    				for(int j = 0; j < 10; j++)
    				{
    					color(block[bag[i * 10 + j]].color);
    					cout << block[bag[i * 10 + j]].ch;
    					color(7);
    					cout << "│";
    				}
    				cout << endl;
    				color(7);
    				cout << "├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤" << endl;
    			}
    			color(7);
    			cout << "│";
    			for(int j = 0; j < 10; j++)
    			{
    				color(block[bag[90 + j]].color);
    				cout << block[bag[90 + j]].ch;
    				color(7);
    				cout << "│";
    			}
    			color(7);
    			cout << endl;
    			cout << "└──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘" << endl;
    			Sleep(3000);
    		}
    		if(KEY_DOWN('C'))
    		{
    			hungry += 100;
    			hungry = min(hungry, 1000);
    		}
    		if(KEY_DOWN('Q'))
    		{
    			for(int i = 0; i < 20; i++)
    			{
    				if(tnt[i].time == -2)
    				{
    					tnt[i] = {y, x, 10, 0};
    					break;
    				}
    			}
    		}
    		if(KEY_DOWN('i'))
    		{
    			for(int i = 0; i < 20; i++)
    			{
    				if(tnt[i].time == -2)
    				{
    					tnt[i] = {y, x, 10, 1};
    					break;
    				}
    			}
    		}
    		if(KEY_DOWN('8'))
    		{
    			for(int i = 0; i < 20; i++)
    			{
    				if(tnt[i].time == -2)
    				{
    					tnt[i] = {y, x, 10, 2};
    					break;
    				}
    			}
    		}
    		if(KEY_DOWN('9'))
    		{
    			for(int i = 0; i < 20; i++)
    			{
    				if(tnt[i].time == -2)
    				{
    					tnt[i] = {y, x, 10, 3};
    					break;
    				}
    			}
    		}
    		if(KEY_DOWN('0'))
    		{
    			for(int i = 0; i < 20; i++)
    			{
    				if(tnt[i].time == -2)
    				{
    					tnt[i] = {y, x, 10, 4};
    					break;
    				}
    			}
    		}
    		if(KEY_DOWN('I'))
    		{
    			for(int i = 0; i < 20; i++)
    			{
    				if(tnt[i].time == -2)
    				{
    					tnt[i] = {y, x, 10, 5};
    					break;
    				}
    			}
    		}
    		if(KEY_DOWN('Z'))
    		{
    			setboard[y + 1][x] = 0;
    		}
    		if(KEY_DOWN('X'))
    		{
    			setboard[y][x] = 24;
    		}
    		if(KEY_DOWN('3'))
    		{
    			setboard[y + 1][x] = 6;
    		}
    		if(KEY_DOWN('4'))
    		{
    			setboard[y + 1][x] = 7;
    		}
    		if(KEY_DOWN('1'))
    		{
    			setboard[y + 1][x] = 8;
    		}
    		if(KEY_DOWN('2'))
    		{
    			setboard[y + 1][x] = 16;
    		}
    		if(KEY_DOWN('5'))
    		{
    			if(face == 1)
    			{
    				for(int i = 0; i < 100; i++)
    				{
    					if(arrow[i].shap == "")
    					{
    						arrow[i] = {"→",y,x,-0.7,2};
    						break; 
    					}
    				}
    			}
    			else
    			{
    				for(int i = 0; i < 100; i++)
    				{
    					if(arrow[i].shap == "")
    					{
    						arrow[i] = {"←",y,x,-0.7,-2};
    						break;
    					}
    				}
    			}
    		}
    		if(KEY_DOWN('T'))
    		{
    			clear_buffer();
    			system("cls");
    			cout << "请输入指令:" << endl;
    			string a;
    			cin >> a;
    			if(a == "kill")
    			{
    				die = "失败了。";
    				hurt = true;
    				health = 0; 
    			}
    			if(a == "full_health")
    			{
    				health = 1000; 
    			}
    			if(a == "creativemode")
    			{
    				mode = !mode;
    			}
    			if(a == "move")
    			{
    				cin >> y >> x;
    				y = 1000 - y;
    			}
    			if(a == "summom")
    			{
    				int a;
    				cin >> a;
    				for(int i = 0; i < 100; i++)
    				{
    					if(mob[i].shap == "")
    					{
    						mob[i] = mobs[a];
    						mob[i].x = x;
    						mob[i].y = y;
    						break;
    					}
    				}
    			}
    		}
    		if(KEY_DOWN('O'))
    		{
    			for(int i = 0; i < 1000; i++)
    			{
    				for(int j = 0; j < 1000; j++)
    				{
    					setboard[i][j] = 0;
    				}
    			}
    		}
    		if(KEY_DOWN('P'))
    		{
    			for(int i = 0; i < 1000; i++)
    			{
    				for(int j = 0; j < 1000; j++)
    				{
    					setboard[i][j] = 2;
    				}
    			}
    		}
    		if(y > 1000)
    		{
    			die = "掉出了这个世界!";
    			hurt = true;
    			health -= 200; 
    		}
    		if(breath <= 0)
    		{
    			breath = 0;
    			hurt = true;
    			health -= 10; 
    		}
    		if(!KEY_DOWN('S') && block[board[y - 1][x]].type == "block")
    		{
    			die = "在墙里窒息死亡!";
    			hurt = true;
    			health -= 50;
    		}
    		if(board[y + 1][x] == 5)
    		{
    			hurt = true;
    			die = "发现了地板是熔岩做的。";
    			health -= 30; 
    		}
    		clear_buffer();
    	}
    	return 0;
    }
    

    最新版狼人杀:

    #include<bits/stdc++.h>
    #include<cstdio>
    #include<cstdlib>
    #include<ctime>
    #include<windows.h>
    using namespace std;
    struct IDname
    {
        int geshu;
        string NAME;
    };
    IDname jue_se[100];
    struct ID
    {
        int num;
        bool life;
        string name;
        int know;
        int how;
    };
    ID player[21];
    int n, MY, kill1, kill2;
    char a;
    bool jieyao = 1, duyao = 1;
    int lieren, shouwei = 0;
    void init1()
    {
        jue_se[1].NAME = "村民 ";
        jue_se[2].NAME = "狼人 ";
        jue_se[3].NAME = "女巫 ";
        jue_se[4].NAME = "预言家 ";
        jue_se[5].NAME = "猎人 ";
        jue_se[6].NAME = "守卫 ";
    }
    void init2(int nn)
    {
        switch (nn)
        {
        case 6:
            jue_se[1].geshu = 3;
            jue_se[2].geshu = 2;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 0;
            jue_se[5].geshu = 0;
            jue_se[6].geshu = 0;
            break;
        case 7:
            jue_se[1].geshu = 3;
            jue_se[2].geshu = 2;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 0;
            jue_se[6].geshu = 0;
            break;
        case 8:
            jue_se[1].geshu = 3;
            jue_se[2].geshu = 3;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 0;
            jue_se[6].geshu = 0;
            break;
        case 9:
            jue_se[1].geshu = 3;
            jue_se[2].geshu = 3;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 1;
            jue_se[6].geshu = 0;
            break;
        case 10:
            jue_se[1].geshu = 4;
            jue_se[2].geshu = 3;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 1;
            jue_se[6].geshu = 0;
            break;
        case 11:
            jue_se[1].geshu = 4;
            jue_se[2].geshu = 4;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 1;
            jue_se[6].geshu = 0;
            break;
        case 12:
            jue_se[1].geshu = 4;
            jue_se[2].geshu = 4;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 1;
            jue_se[6].geshu = 1;
            break;
        default:
            cout << "输入错误,再见" << endl;
            exit(0);
            break;
        }
    }
    int van[10] = { 7,4,6,43,35,1,2,8,20,19 };
    void init3(int nn)
    {
        srand(time(0));
        Sleep(rand() % 44);
        int x = 10000;
        int t = rand();
        srand(time(NULL));
        int y = van[(rand() % 100 * van[rand() % 10] + t) % 10];
        if (nn <= 6)
            x = abs(x * 6 / y) % 3 + 1;
        else if (nn <= 8)
            x = abs(x * 7 / y) % 4 + 1;
        else if (nn <= 11)
            x = abs(x * 8 / y) % 5 + 1;
        else if (nn <= 14)
            x = abs(x * 9 / y) % 6 + 1;
        do
        {
            if (nn <= 6)
                x = x % 3 + 1;
            else if (nn <= 8)
                x = x % 4 + 1;
            else if (nn <= 11)
                x = x % 5 + 1;
            else if (nn <= 14)
                x = x % 6 + 1;
            if (jue_se[x].geshu > 0)
            {
                player[nn].name = jue_se[x].NAME;
                if (player[nn].name == "猎人 ")
                    lieren = nn;
                if (player[nn].name == "守卫 ")
                    shouwei = nn;
                player[nn].life = 1;
                player[nn].num = nn;
                player[nn].know = 0;
                jue_se[x].geshu--;
                player[nn].how = 0;
                break;
            }
        } while (jue_se[x].geshu == 0);
    }
    void printhhh()
    {
        int cm = 0;
        int sz = 0;
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 0)
                continue;
            else if (player[i].name == "村民 ")
                cm++;
            else if (player[i].name == "女巫 " || player[i].name == "预言家 " || player[i].name == "猎人 " || player[i].name == "守卫 ")
                sz++;
        }
        if (sz == 0 || cm == 0)
            cout << "狼人阵营胜利" << endl;
        else
            cout << "好人阵营胜利" << endl;
        for (int i = 1; i <= n; i++)
        {
            cout << left << setw(3) << player[i].num << ": " << player[i].name << " ";
            if (player[i].life == 0)
                cout << "死亡" << "\t";
            else
                cout << "存活" << "\t";
            if (player[i].how == 0)
                cout << "最终存活 " << endl;
            else if (player[i].how == 1)
                cout << "最终被狼人杀死" << endl;
            else if (player[i].how == 2)
                cout << "最终被投票投死" << endl;
            else if (player[i].how == 3)
                cout << "最终被女巫毒死" << endl;
            else if (player[i].how == 4)
                cout << "最终被猎人射杀" << endl;
        }
        system("pause");
        system("pause");
        system("pause");
    }
    void print(int day, int ti)
    {
        HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
        if (ti == 0)
            SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
        else
            SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
        cout << "\t\t\t\t第" << day << "天 ";
        if (ti == 0)
            cout << "白天" << endl;
        else
            cout << "夜晚" << endl;
        cout << "我的位置:" << MY << "号" << endl;
        for (int i = 1; i <= 6; i++)
        {
            cout << player[i].num << "号位 ";
        }
        cout << endl;
        for (int i = 1; i <= 6; i++)
        {
            if (player[i].life == 1)
            {
                if (ti == 0)
                    SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_GREEN);
                else
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
                cout << "存活 ";
            }
            else
            {
                if (ti == 0)
                    SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
                else
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
                cout << "已死亡 ";
            }
        }
        if (ti == 0)
            SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
        else
            SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
        cout << endl;
        for (int i = 1; i <= 6; i++)
        {
            if (player[i].know == 0)
                cout << "未知 ";
            else if (player[i].know == 1)
            {
                if (player[i].name == "狼人 ")
                    cout << "狼人 ";
                else
                    cout << "好人 ";
            }
            else if (player[i].know == 2)
                cout << player[i].name << " ";
        }
        cout << endl << endl;
        for (int i = 7; i <= n; i++)
        {
            if (i < 10)
                cout << player[i].num << "号位 ";
            else
                cout << player[i].num << "号位 ";
        }
        cout << endl;
        for (int i = 7; i <= n; i++)
        {
            if (player[i].life == 1)
            {
                if (ti == 0)
                    SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_GREEN);
                else
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
                cout << "存活 ";
            }
            else
            {
                if (ti == 0)
                    SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
                else
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
                cout << "已死亡 ";
            }
        }
        if (ti == 0)
            SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
        else
            SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
        cout << endl;
        for (int i = 7; i <= n; i++)
        {
            if (player[i].know == 0)
                cout << "未知 ";
            else if (player[i].know == 1)
            {
                if (player[i].name == "狼人 ")
                    cout << "狼人 ";
                else
                    cout << "好人 ";
            }
            else if (player[i].know == 2)
                cout << player[i].name << " ";
        }
        cout << endl << endl;
    }
    int shou = 0;
    void shoushui(int hhh, int hhhh)
    {
        int x;
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "守~卫~请~睁~眼~~~" << endl;
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        if (MY == shouwei && player[MY].life == 1)
        {
            cout << "请问你要守护谁?" << endl << "输入:";
            cin >> x;
            while (x == shou || x<1 || x>n || player[x].life == 0)
            {
                cout << "输入错误,请重新输入" << endl << "输入:";
                cin >> x;
            }
            shou = x;
        }
        else if (player[shouwei].life == 1)
        {
            cout << "请问你要守护谁?" << endl;
            Sleep(rand() % 98);
            srand(time(0));
            x = rand() % n + 1;
            while (x == shou || player[x].life == 0)
            {
                Sleep(rand() % 98);
                srand(time(0));
                x = rand() % n + 1;
            }
            shou = x;
        }
        else
        {
            cout << "请问你要守护谁?" << endl;
            Sleep(3000);
            shou = -1;
        }
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "守~卫~请~闭~眼~~~" << endl;
    }
    struct tou
    {
        int xxx;
        int num;
        int toupiaoquan;
    };
    tou TOU[13];
    bool cmp(tou x, tou y)
    {
        if (x.xxx == y.xxx)
            return x.num < y.num;
        return x.xxx > y.xxx;
    }
    bool cmp1(tou x, tou y)
    {
        return x.num < y.num;
    }
    void toupiao(int ddd, int nnn)
    {
        //--------1--------
        int x;
        Sleep(2000);
        system("cls");
        print(ddd, nnn);
        cout << "现在大家请投票";
        for (int i = 1; i <= 3; i++)
        {
            cout << ".";
            Sleep(500);
        }
        cout << endl;
        for (int i = 1; i <= n; i++)
        {
            TOU[i].num = i;
            TOU[i].toupiaoquan = 1;
            TOU[i].xxx = 0;
        }
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 1)
            {
                Sleep(3000);
                if (i == MY)
                {
                    cout << "请投票...(0弃权)" << endl;
                    cin >> x;
                    while (player[x].life == 0 && x != 0)
                    {
                        cin >> x;
                    }
                    if (x == 0)
                        cout << MY << "号玩家弃权" << endl;
                    else
                        cout << MY << "号玩家投给了" << x << "号玩家" << endl;
                }
                else
                {
                    srand(time(0));
                    if (player[i].name == "狼人 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i))
                        {
                            Sleep(rand() % 98);
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else if (player[i].name == "预言家 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i))
                        {
                            Sleep(rand() % 98);
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || x == i))
                        {
                            Sleep(rand() % 98);
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                }
                if (x != 0)
                    TOU[x].xxx++;
            }
        }
        Sleep(3000);
        sort(TOU + 1, TOU + n + 1, cmp);
        if (TOU[2].xxx != TOU[1].xxx)
        {
            cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
            player[TOU[1].num].life = 0;
            player[TOU[1].num].how = 2;
            Sleep(3000);
            return;
        }
        else
        {
            TOU[1].toupiaoquan = 0;
            TOU[2].toupiaoquan = 0;
            system("cls");
            print(ddd, nnn);
            cout << TOU[1].num << "号," << TOU[2].num << "号";
            int i;
            for (i = 3; i <= n; i++)
            {
                if (TOU[i].xxx == TOU[1].xxx)
                {
                    TOU[i].toupiaoquan = 0;
                    cout << "," << TOU[i].num << "号";
                }
                else
                    break;
            }
            if (i == n + 1)
            {
                for (int i = 1; i <= n; i++)
                    TOU[i].toupiaoquan = 1;
            }
            cout << "平票" << endl;
        }
        //--------2--------
        sort(TOU + 1, TOU + n + 1, cmp1);
        cout << "请再次投票";
        for (int i = 1; i <= 3; i++)
        {
            cout << ".";
            Sleep(500);
        }
        cout << endl;
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 1 && TOU[i].toupiaoquan == 1)
            {
                Sleep(3000);
                if (i == MY)
                {
                    cout << "请投票...(0弃权)" << endl;
                    cin >> x;
                    while ((player[x].life == 0 || TOU[x].toupiaoquan == 1) && x != 0)
                    {
                        cin >> x;
                    }
                    if (x == 0)
                        cout << MY << "号玩家弃权" << endl;
                    else
                        cout << MY << "号玩家投给了" << x << "号玩家" << endl;
                }
                else
                {
                    srand(time(0));
                    if (player[i].name == "狼人 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else if (player[i].name == "预言家 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                }
                if (x != 0 && TOU[i].toupiaoquan == 1)
                    TOU[x].xxx++;
            }
        }
        Sleep(3000);
        sort(TOU + 1, TOU + n + 1, cmp);
        if (TOU[2].xxx != TOU[1].xxx)
        {
            cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
            player[TOU[1].num].life = 0;
            player[TOU[1].num].how = 2;
            Sleep(3000);
            return;
        }
        else
        {
            TOU[1].toupiaoquan = 0;
            TOU[2].toupiaoquan = 0;
            system("cls");
            print(ddd, nnn);
            cout << TOU[1].num << "号," << TOU[2].num << "号";
            int i;
            for (i = 3; i <= n; i++)
            {
                if (TOU[i].xxx == TOU[1].xxx)
                {
                    TOU[i].toupiaoquan = 0;
                    cout << "," << TOU[i].num << "号";
                }
                else
                    break;
            }
            if (i == n + 1)
            {
                for (int i = 1; i <= n; i++)
                    TOU[i].toupiaoquan = 1;
            }
            cout << "平票" << endl;
        }
        //--------3--------
        sort(TOU + 1, TOU + n + 1, cmp1);
        cout << "请再次投票";
        for (int i = 1; i <= 3; i++)
        {
            cout << ".";
            Sleep(500);
        }
        cout << endl;
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 1 && TOU[i].toupiaoquan == 1)
            {
                Sleep(3000);
                if (i == MY)
                {
                    cout << "请投票...(0弃权)" << endl;
                    cin >> x;
                    while ((player[x].life == 0 || TOU[x].toupiaoquan == 1) && x != 0)
                    {
                        cin >> x;
                    }
                    if (x == 0)
                        cout << MY << "号玩家弃权" << endl;
                    else
                        cout << MY << "号玩家投给了" << x << "号玩家" << endl;
                }
                else
                {
                    srand(time(0));
                    if (player[i].name == "狼人 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else if (player[i].name == "预言家 " || player[i].name == "猎人 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                }
                if (x != 0 && TOU[i].toupiaoquan == 1)
                    TOU[x].xxx++;
            }
        }
        Sleep(3000);
        sort(TOU + 1, TOU + n + 1, cmp);
        if (TOU[2].xxx != TOU[1].xxx)
        {
            cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
            player[TOU[1].num].life = 0;
            player[TOU[1].num].how = 2;
        }
        else
        {
            cout << "投票结束,无人出局" << endl;
        }
        Sleep(5000);
    }
    bool game_over()
    {
        int pingmin = 0;
        int langren = 0;
        int shenzhi = 0;
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 0)
                continue;
            if (player[i].name == "狼人 ")
                langren++;
            else if (player[i].name == "村民 ")
                pingmin++;
            else if (player[i].name == "女巫 " || player[i].name == "预言家 " || player[i].name == "猎人 ")
                shenzhi++;
        }
        if (shenzhi == 0 || langren == 0 || pingmin == 0)
            return 1;
        return 0;
    }
    void night()
    {
        system("cls");
        system("color 0f");
        print(1, 1);
        cout << "天~黑~请~闭~眼~~~" << endl;
        if (n >= 12)
            shoushui(1, 1);
        Sleep(3000);
        system("cls");
        print(1, 1);
        cout << "狼~人~请~睁~眼~~~" << endl;
        if (player[MY].name == "狼人 ")
        {
            Sleep(1000);
            cout << "你的同伴有:";
            for (int i = 1; i <= n; i++)
            {
                if (i == MY)
                    continue;
                if (player[i].name == "狼人 ")
                {
                    cout << player[i].num << "号 ";
                    player[i].know = 2;
                }
            }
            Sleep(3000);
            cout << endl << "请问你们要杀谁:" << endl << "输入:";
            cin >> kill1;
            Sleep(1500);
            system("cls");
            print(1, 1);
            cout << "今晚你们要杀的是" << kill1 << "号玩家" << endl;
        }
        else
        {
            Sleep(4000);
            system("cls");
            print(1, 1);
            cout << "请问你们要杀谁?" << endl;
            do
            {
                Sleep(rand() % 18);
                srand(time(0));
                int x = rand() % n + 1;
                if (player[x].name != "狼人 " && player[x].life == 1)
                {
                    kill1 = x;
                    break;
                }
            } while (1);
            Sleep(5000);
        }
        Sleep(3000);
        system("cls");
        print(1, 1);
        cout << "狼~人~请~闭~眼~~~" << endl;
        Sleep(2000);
        system("cls");
        print(1, 1);
        cout << "女~巫~请~睁~眼~~~" << endl;
        Sleep(2000);
        system("cls");
        print(1, 1);
        if (player[MY].name == "女巫 " && player[MY].life == 1)
        {
            Sleep(1000);
            if (jieyao == 1)
            {
                cout << "今晚" << kill1 << "号玩家被杀" << endl;
                Sleep(500);
                cout << "请问你要救吗???" << endl << "A. 救 B.不救" << endl << "输入:";
                cin >> a;
                if (a == 'A')
                {
                    system("cls");
                    print(1, 1);
                    cout << "请问你要毒吗???" << endl;
                    Sleep(2000);
                    system("cls");
                    print(1, 1);
                    cout << "今晚" << kill1 << "号玩家被你解救" << endl;
                    jieyao = 0;
                    if (shou != kill1)
                        kill1 = 0;
                }
                else
                {
                    if (shou == kill1)
                        kill1 = 0;
                    Sleep(2000);
                    system("cls");
                    print(1, 1);
                    cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
                    cin >> a;
                    if (a == 'A')
                    {
                        cout << "请问你要毒谁???" << endl << "输入:";
                        cin >> kill2;
                        while (player[kill2].life != 1)
                        {
                            cout << "输入错误,请重新输入:" << endl;
                            cin >> kill2;
                        }
                        duyao = 0;
                    }
                }
            }
            else
            {
                if (shou == kill1)
                    kill1 = 0;
                Sleep(2000);
                system("cls");
                print(1, 1);
                cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
                cin >> a;
                if (a == 'A')
                {
                    cout << "请问你要毒谁???" << endl << "输入:";
                    cin >> kill2;
                    while (player[kill2].life != 1)
                    {
                        cout << "输入错误,请重新输入:" << endl;
                        cin >> kill2;
                    }
                    duyao = 0;
                }
            }
        }
        else
        {
            bool b = 0;
            cout << "请问你是否要用解药???" << endl;
            int FFF = 0, kkkk;
            for (int i = 1; i <= n; i++)
            {
                if (player[i].life == 1 && player[i].name == "村民 ")
                    FFF++;
                if (player[i].name == "女巫 ")
                    kkkk = i;
            }
            if (jieyao == 1 && player[kkkk].life == 1)
            {
                if (FFF == 1)
                {
                    if (shou == kill1)
                        jieyao = 1;
                    else
                        jieyao = 0;
                    kill1 = 0;
                    b = 1;
                }
                else
                    for (int i = 1; i <= n; i++)
                    {
                        if (player[i].name == "女巫 " && kill1 == i)
                        {
                            kill1 = 0;
                            if (shou == kill1)
                                jieyao = 1;
                            else
                                jieyao = 0;
                            b = 1;
                            break;
                        }
                        else if (player[i].name == "预言家 " && kill1 == i)
                        {
                            kill1 = 0;
                            if (shou == kill1)
                                jieyao = 1;
                            else
                                jieyao = 0;
                            b = 1;
                            break;
                        }
                    }
            }
            Sleep(3000);
            if (b == 0 && duyao == 1 && player[kkkk].life == 1)
            {
                system("cls");
                print(1, 1);
                cout << "请问你是否要用毒药???" << endl;
                srand(time(0));
                int x = rand() % 2;
                Sleep(1500);
                cout << "请问你要毒谁???" << endl;
                if (x == 1)
                {
                    duyao = 0;
                    int y = rand() % n + 1;
                    while ((player[y].name == "女巫 " || player[y].name == "预言家 " || y == kill1) || player[y].life == 0)
                        y = rand() % n + 1;
                    kill2 = y;
                }
            }
            else
            {
                Sleep(3000);
                system("cls");
                print(1, 1);
                cout << "请问你是否要用毒药???" << endl;
                Sleep(3000);
                cout << "请问你要毒谁???" << endl;
                Sleep(3000);
            }
        }
        Sleep(3000);
        system("cls");
        print(1, 1);
        cout << "女~巫~请~闭~眼~~~" << endl;
        if (n > 6)
        {
            Sleep(3000);
            system("cls");
            print(1, 1);
            cout << "预~言~家~请~睁~眼~~~" << endl;
            if (player[MY].name == "预言家 ")
            {
                Sleep(3000);
                cout << "请问你想查验谁???" << endl << "输入:";
                int x;
                cin >> x;
                player[x].know = 1;
                Sleep(2000);
                system("cls");
                print(1, 1);
                cout << "他的身份是:";
                if (player[x].name == "狼人 ")
                    cout << "狼人" << endl;
                else
                    cout << "好人" << endl;
                Sleep(3000);
            }
            else
            {
                Sleep(3000);
                cout << "请问你想查验谁???" << endl;
                Sleep(3000);
                system("cls");
                print(1, 1);
                cout << "他的身份是:......";
                Sleep(3000);
            }
            Sleep(3000);
            system("cls");
            print(1, 1);
            cout << "预~言~家~请~闭~眼~~~" << endl;
        }
        Sleep(3000);
        if (kill1 != 0)
            player[kill1].life = 0;
        if (kill2 != 0)
            player[kill2].life = 0;
        player[kill1].how = 1;
        player[kill2].how = 3;
        system("cls");
        system("color F0");
        print(2, 0);
    }
    void night2(int hhh, int hhhh)
    {
        system("cls");
        system("color 0f");
        print(hhh, hhhh);
        cout << "天~黑~请~闭~眼~~~" << endl;
        if (n >= 12)
            shoushui(hhh, hhhh);
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "狼~人~请~睁~眼~~~" << endl;
        if (player[MY].name == "狼人 " && player[MY].life == 1)
        {
            Sleep(3000);
            cout << endl << "请问你们要杀谁:" << endl << "输入:";
            cin >> kill1;
            Sleep(1500);
            system("cls");
            print(hhh, hhhh);
            cout << "今晚你们要杀的是" << kill1 << "号玩家" << endl;
        }
        else
        {
            Sleep(4000);
            system("cls");
            print(hhh, hhhh);
            cout << "请问你们要杀谁?" << endl;
            do
            {
                srand(time(0));
                int x = rand() % n + 1;
                if (player[x].name != "狼人 " && player[x].life == 1)
                {
                    kill1 = x;
                    break;
                }
            } while (1);
            Sleep(5000);
        }
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "狼~人~请~闭~眼~~~" << endl;
        Sleep(2000);
        system("cls");
        print(hhh, hhhh);
        cout << "女~巫~请~睁~眼~~~" << endl;
        Sleep(2000);
        system("cls");
        print(hhh, hhhh);
        if (player[MY].name == "女巫 " && player[MY].life == 1)
        {
            Sleep(1000);
            if (jieyao == 1)
            {
                cout << "今晚" << kill1 << "号玩家被杀" << endl;
                Sleep(500);
                cout << "请问你要救吗???" << endl << "A. 救 B.不救" << endl << "输入:";
                cin >> a;
                if (a == 'A')
                {
                    system("cls");
                    print(hhh, hhhh);
                    cout << "请问你要毒吗???" << endl;
                    Sleep(2000);
                    system("cls");
                    print(hhh, hhhh);
                    cout << "今晚" << kill1 << "号玩家被你解救" << endl;
                    jieyao = 0;
                    if (shou != kill1)
                        kill1 = 0;
                }
                else
                {
                    if (shou == kill1)
                        kill1 = 0;
                    Sleep(2000);
                    system("cls");
                    print(hhh, hhhh);
                    cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
                    cin >> a;
                    if (a == 'A')
                    {
                        cout << "请问你要毒谁???" << endl << "输入:";
                        cin >> kill2;
                        while (player[kill2].life != 1)
                        {
                            cout << "输入错误,请重新输入:" << endl;
                            cin >> kill2;
                        }
                        duyao = 0;
                    }
                }
            }
            else if (duyao == 1)
            {
                if (shou == kill1)
                    kill1 = 0;
                Sleep(2000);
                system("cls");
                print(hhh, hhhh);
                cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
                cin >> a;
                if (a == 'A')
                {
                    cout << "请问你要毒谁???" << endl << "输入:";
                    cin >> kill2;
                    while (player[kill2].life != 1)
                    {
                        cout << "输入错误,请重新输入:" << endl;
                        cin >> kill2;
                    }
                    duyao = 0;
                }
            }
            else
            {
                Sleep(2000);
                system("cls");
                print(hhh, hhhh);
                cout << "请问你要毒吗???" << endl;
            }
        }
        else
        {
            bool b = 0;
            cout << "请问你是否要用解药???" << endl;
            int FFF = 0, kkkk;
            for (int i = 1; i <= n; i++)
            {
                if (player[i].life == 1 && player[i].name == "村民 ")
                    FFF++;
                if (player[i].name == "女巫 ")
                    kkkk = i;
            }
            if (jieyao == 1 && player[kkkk].life == 1)
            {
                if (FFF == 1)
                {
                    if (shou == kill1)
                        jieyao = 1;
                    else
                        jieyao = 0;
                    kill1 = 0;
                    b = 1;
                }
                else
                    for (int i = 1; i <= n; i++)
                    {
                        if (player[i].name == "女巫 " && kill1 == i)
                        {
                            kill1 = 0;
                            if (shou == kill1)
                                jieyao = 1;
                            else
                                jieyao = 0;
                            b = 1;
                            break;
                        }
                        else if (player[i].name == "预言家 " && kill1 == i)
                        {
                            kill1 = 0;
                            if (shou == kill1)
                                jieyao = 1;
                            else
                                jieyao = 0;
                            b = 1;
                            break;
                        }
                    }
            }
            Sleep(3000);
            if (b == 0 && duyao == 1 && player[kkkk].life == 1)
            {
                system("cls");
                print(hhh, hhhh);
                cout << "请问你是否要用毒药???" << endl;
                srand(time(0));
                int x = rand() % 2;
                Sleep(1500);
                cout << "请问你要毒谁???" << endl;
                if (x == 1)
                {
                    duyao = 0;
                    int y = rand() % n + 1;
                    while ((player[y].name == "女巫 " || player[y].name == "预言家 " || y == kill1) || player[y].life == 0)
                        y = rand() % n + 1;
                    kill2 = y;
                }
            }
            else
            {
                Sleep(3000);
                system("cls");
                print(hhh, hhhh);
                cout << "请问你是否要用毒药???" << endl;
                Sleep(3000);
                cout << "请问你要毒谁???" << endl;
                Sleep(3000);
            }
        }
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "女~巫~请~闭~眼~~~" << endl;
        if (n > 6)
        {
            Sleep(3000);
            system("cls");
            print(hhh, hhhh);
            cout << "预~言~家~请~睁~眼~~~" << endl;
            if (player[MY].name == "预言家 " && player[MY].life == 1)
            {
                Sleep(3000);
                cout << "请问你想查验谁???" << endl << "输入:";
                int x;
                cin >> x;
                player[x].know = 1;
                Sleep(2000);
                system("cls");
                print(hhh, hhhh);
                cout << "他的身份是:";
                if (player[x].name == "狼人 ")
                    cout << "狼人" << endl;
                else
                    cout << "好人" << endl;
                Sleep(3000);
            }
            else
            {
                Sleep(3000);
                cout << "请问你想查验谁???" << endl;
                Sleep(3000);
                system("cls");
                print(hhh, hhhh);
                cout << "他的身份是:......";
                Sleep(3000);
            }
            Sleep(3000);
            system("cls");
            print(hhh, hhhh);
            cout << "预~言~家~请~闭~眼~~~" << endl;
        }
        Sleep(3000);
        if (kill1 != 0)
            player[kill1].life = 0;
        if (kill2 != 0)
            player[kill2].life = 0;
        player[kill1].how = 1;
        player[kill2].how = 3;
        system("cls");
        system("color F0");
        print(hhh + 1, 0);
    }
    bool lr = 0;
    void panduanlieren()
    {
        if (lr == 1)
            return;
        if (MY == lieren)
        {
            cout << "请射杀一名玩家" << endl;
            int x;
            cin >> x;
            while (player[x].life != 1)
            {
                cout << "输入错误,请重新输入" << endl;
                cin >> x;
            }
            Sleep(1000);
            cout << lieren << "号猎人发动技能,开枪带走了" << x << "号" << endl;
            player[x].life = 0;
            player[x].how = 4;
        }
        else if (n >= 9)
        {
            srand(time(0));
            int x = rand() % n + 1;
            while (player[x].life != 1)
            {
                x = rand() % n + 1;
            }
            Sleep(1000);
            cout << lieren << "号猎人发动技能,开枪带走了" << x << "号" << endl;
            player[x].life = 0;
            player[x].how = 4;
        }
        lr = 1;
    }
    void print1()
    {
        cout << "天亮了,昨晚";
        if (kill1 != 0 || kill2 != 0)
        {
            cout << kill1 << "号";
            if (kill2 != 0)
            {
                cout << "," << kill2 << "号";
                kill2 = 0;
            }
            cout << "被杀" << endl;
        }
        else
            cout << "是平安夜" << endl;
    }
    int main()
    {
        system("cls");
        cout << " " << "狼人杀online" << endl;
        cout << "请输入人数个数:" << endl;
        scanf("%d", &n);
        cout << "加载时间长,请耐心等待";
        init1();
        init2(n);
        int k = 1;
        do
        {
            srand(time(0));
            init3(k);
            cout << ".";
            Sleep(17);
            k++;
        } while (k <= n);
        system("cls");
        system("color F0");
        cout << "游戏即将开始";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        Sleep(1500);
        cout << endl << endl << "请大家查看身份牌......" << endl;
        Sleep(45);
        srand(time(0));
        MY = rand() % n + 1;
        cout << "您的身份是:" << player[MY].name << endl;
        Sleep(500);
        cout << "在" << player[MY].num << "号位上" << endl;
        system("pause");
        system("cls");
        player[MY].know = 2;
        print(1, 0);
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night();
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(2, 0);
        system("cls");
        print(2, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night2(2, 1);
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(3, 0);
        system("cls");
        print(3, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night2(3, 1);
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(4, 0);
        system("cls");
        print(4, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night2(4, 1);
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(5, 0);
        system("cls");
        print(5, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night2(5, 1);
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(6, 0);
        system("cls");
        print(6, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night2(6, 1);
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(7, 0);
        system("cls");
        print(7, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        while (1)
            system("pause");
        return 0;
    }
    
  • 通过的题目

题目标签

语言基础
88
循环语句
59
语言入门
30
一维数组
29
选择语句
28
字符串
21
其他
19
字符数组
19
二维数组
14
竞赛
13
NOIP
12
搜索
8
输入输出
8
位运算
7
递归
7
普及组
7
高精度
7
贪心
6
模拟
5
DFS
5