c++小游戏2

接上集

注:这些是作者搜集的,不是原创,请不要误会

1,三国杀

#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("游戏开始!\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;
	}
}

2,猜数

#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<ctime>
#include<cstdio>
#include<conio.h>
using namespace std;
int n,m;
bool c[100005];
int main()
{
    cout<<"猜数 3.2\n"; 
    srand(time(NULL));
    cout<<"==============================================================\n几人猜数(只支持100000人以内)??";
    cin>>n;
    cout<<"==============================================================\n0~几??";
    cin>>m;
    for(;;)
    {
        cout<<"==============================================================\n开始!!!";
        int x=rand()%(m+1),y,h=0,e=m,t=rand()%n;
        bool hh=1,ee=1;
        do
        {
            cout<<"\n==============================================================\n";
            cout<<h<<"~"<<e<<endl;
            ++t;
            t-=t>n?n:0;
            if(!c[t])
              cout<<t<<"号猜(电脑帮猜?输-1 设置TA为电脑?输-2)",cin>>y;
            if(y==-2)
              c[t]=1;
            if(y==-1||c[t])
            {
                y=(h+e)/2;
                cout<<"帮"<<t<<"号猜猜成"<<y<<endl;
                if(y==x)
                  break;
                if(y>x)
                {
                    cout<<"大了";
                    e=y; 
                    continue;
                }
                if(y<x)
                {
                    cout<<"小了";
                    h=y; 
                    continue;
                }
            } 
            if(y<=h||y>=e)
            {
                cout<<"浪费机会!!!";
                continue;
                if(!h&&!y)
                  if(hh)
                    hh=0;
                else
                {
                    cout<<"浪费机会!!!";
                    continue;
                }
                if(e==m&&y==m)
                  if(ee)
                    ee=0;
                else
                {
                    cout<<"浪费机会!!!";
                    continue;
                }
            }
            if(y>x)
            {
                cout<<"大了";
                e=y; 
            }
            if(y<x)
            {
                cout<<"小了";
                h=y; 
            }
        }while(x!=y);
        cout<<t<<"号赢了!!!\n==============================================================\n再来一局吗?\ny/n\n";
        char a;
        a=getch();
        if(a=='n'||a=='N')
          break; 
    }
    getchar();
    cout<<"==============================================================\nbyebye!\n==============================================================\n双击任意键结束,单机空格关机!";
    char a=getch();
    if(a==' ')
    {
        cout<<"\n确定吗??确定点空格一下,否则双击任意键结束。";
        a=getch();
        if(a==' ')
          system("shutdown -s -t 0");
    }
    return 0; 
}

3,斗地主

 
#include<bits/stdc++.h>
#define PLAYERCOUNT 3
#define CARDSCOUNT 54
#define CURRENTPLAYER 0
#define VALUECOUNT 17
#define ERROR -1
 
using namespace std;
const char toFigure[]="34567890JQKA 2YZ";
enum COLOR{  //花色显示ASCII: 3~6
    eHEART=3,//红桃 
    eDIAMOND,//方片 
    eCLUB,   //草花 
    eSPADE   //黑桃 
};
 
class Card;
class CardsType;
class CardGroup;
class Player;
class Landlords;
class LastCards;
bool makeChoice(string tip);
bool cmp(Card* a,Card* b);
 
class Card{
  public:
    char figure;
    COLOR color;
    int value;
    Card(char _figure,COLOR _color){
        figure=_figure;
        color=_color;
        value=calValue();
    }
    int calValue(){
        for(int i=0;toFigure[i];i++){
            if(toFigure[i]==figure){
                return i;
            }
        }
        return ERROR;
    }
    void print(){
        assert(value!=ERROR);
        if(figure=='Z'){
            cout<<"ZZ";
        }else if(figure=='Y'){
            cout<<"YY";
        }else{
            cout<<figure<<(char)color;
        }
        cout<<' ';
    }
};
 
class CardsType{
  public:
    //为了规范查找对应牌的方法
    //统一为3个参数cnt1、isContinuous、cnt2
    int typeId;
    string typeStr;
    int cnt1,cnt2;
    bool isContinuous;
    CardsType(){
        typeId=ERROR;
    }
    bool operator ==(const CardsType& other)const{
        return this->typeId==other.typeId;
    }
    void init(char* _typeStr,int _typeId,int _cnt1,bool _isContinuous,int _cnt2){
        cnt1=_cnt1;
        isContinuous=_isContinuous;
        cnt2=_cnt2;
        typeStr=_typeStr;
        typeId=_typeId;
    }
}; 
 
class CardGroup{
  public:
    vector<Card*> cards;
    CardsType type;
    void calType(){
        int i,n=cards.size();
        //init(typeStr,typeId,cnt1,isContinuous,cnt2)
        if(n==0){
            type.init("不出",14,0,0,0);
            return;
        }
        if(n==2&&cards[0]->value==15&&cards[1]->value==14){
            type.init("王炸",0,0,0,0);
            return;
        }
        //统计同点数牌有多少张 
        int cntFlag[VALUECOUNT]={0};
        for(i=0;i<n;i++){
            cntFlag[cards[i]->value]++;
        }
        //统计点数最多和最少的牌 
        int maxCnt=0,minCnt=4;
        for(i=0;i<VALUECOUNT;i++){ 
            if(maxCnt<cntFlag[i]){
               maxCnt=cntFlag[i];
            }
            if(cntFlag[i]&&minCnt>cntFlag[i]){
               minCnt=cntFlag[i];
            }
        }
        if(n==4&&maxCnt==4){
            type.init("炸dan",1,4,0,0);
            return;
        }
        if(n==1){
            type.init("单牌",2,1,0,0);
            return;
        }
        if(n==2&&maxCnt==2){
            type.init("对子",3,2,0,0);
            return;
        }
        if(n==3&&maxCnt==3){
            type.init("三张 ",4,3,0,0);
            return;
        }
        if(n==4&&maxCnt==3){
            type.init("三带一",5,3,0,1);
            return;
        }
        if(n==5&&maxCnt==3&&minCnt==2){
            type.init("三带一对",6,3,0,2);
            return;
        }
        if(n==6&&maxCnt==4){
            type.init("四带二",7,4,0,1);
            return;
        }
        if(n==8&&maxCnt==4&&minCnt==2){
            type.init("四带二",8,4,0,2);
            return;
        } 
        if(n>=5&&maxCnt==1&&cards[0]->value==cards[n-1]->value+n-1){
            type.init("顺子",9,1,1,0);
            return;
        }
        if(n>=6&&maxCnt==2&&minCnt==2&&cards[0]->value==cards[n-1]->value+n/2-1){
            type.init("连对",10,2,1,0); 
            return;
        }
        int fjCnt;//统计连续且大于3三张的牌 
        for(i=0;i<VALUECOUNT &&cntFlag[i]<3;i++);
        for(fjCnt=0;i<VALUECOUNT &&cntFlag[i]>=3;i++,fjCnt++);
        if(fjCnt>1){
            if(n==fjCnt*3)
                type.init("飞机",11,3,1,0);
            else if(n==fjCnt*4)
                type.init("飞机",12,3,1,1); 
            else if(n==fjCnt*5&&minCnt==2)
                type.init("飞机",13,3,1,2); 
        }
    }
    void init(string inputStr, vector<Card*> &cardsHolded){
        this->cards.clear();
        //不出 
        if(inputStr=="N"){
            this->calType();
            return;
        }
        int i,j;
        //输入合法性判断 
        for(i=0;i<inputStr.size();i++){
            bool find=false;
            for(j=0;toFigure[j];j++){ 
                if(inputStr[i]==toFigure[j]){
                    find=true;
                    break;
                }
            } 
            if(find==false){
                //输入字符不在toFigure中
                return;
            }
        }
        //查找手中有没有这些牌 
        int visitFlag[20]={0};
        for(i=0;i<inputStr.size();i++){
            Card *find=NULL;
            for(j=0;j<cardsHolded.size();j++){
                if(!visitFlag[j]&&cardsHolded[j]->figure==inputStr[i]){
                    visitFlag[j]=1;
                    find=cardsHolded[j];
                    break;
                }
            }
            if(find){
                this->cards.push_back(find);
            }else{
                cout<<inputStr[i];
                cout<<"没有找到\t";
                this->cards.clear();
                return;
            }
        }//end for(i=0;i<inputStr.size();i++) 
        this->arrange();
    }
    void init(vector<Card*> newCards){
        this->cards=newCards;
        this->arrange();
    }
    bool isCanBeat(CardGroup &cardGroup){
        if(cardGroup.type.typeStr=="王炸"){
            return false;
        }else if(this->type.typeStr=="王炸"){
            return true;
        }else if(cardGroup.type==this->type &&this->type.typeStr=="炸dan"){
            return value()>cardGroup.value();
        }else if(cardGroup.type.typeStr=="炸dan"){
            return false;
        }else if(this->type.typeStr=="炸dan"){
            return true;
        }else if(cardGroup.type==this->type &&this->cards.size()==cardGroup.cards.size()){
            return this->value()>cardGroup.value();
        }else{
            return false;
        }
    }
    int value(){
        //计算牌组权值 
        int i;
        if(type.typeStr=="三带一"||type.typeStr=="三带一对"||type.typeStr=="飞机"){
            for(i=2;i<cards.size();i++){
                if(cards[i]->value==cards[i-2]->value){
                    return cards[i]->value;
                }
            }
        }
        if(type.typeStr=="四带二"){
            for(i=3;i<cards.size();i++){
                if(cards[i]->value==cards[i-3]->value){
                    return cards[i]->value;
                }
            }
        }
        return cards[0]->value;
    }
    void arrange(){
        //整理:排序、计算类型 
        sort(this->cards.begin(),this->cards.end(),cmp);
        this->calType();
    }
};
class LastCards{
    static LastCards *lastCards;
  public:
    Player *player;
    CardGroup cardGroup;
    static LastCards* inst(){//单例模式 
        if(lastCards==NULL){
            lastCards=new LastCards();
        }
        return lastCards;
    }
    vector<Card*> findCanBeatFrom(vector<Card*> &cardsHolded){
        //查找能打得过的牌 
        int i,j,k,n=cardsHolded.size(),m=cardGroup.cards.size();
        string typeStr=cardGroup.type.typeStr;
        vector<Card*> ret;
        if(typeStr=="王炸"||n<m){
            //打不过,返回空数组 
            return ret;
        }
        int value=cardGroup.value();
        //统计各点牌出现的次数 
        int cntFlag[VALUECOUNT]={0};
        for(i=0;i<n;i++){ 
            cntFlag[cardsHolded[i]->value]++;
        } 
        int continuousCount=1;
        if(cardGroup.type.isContinuous){
            continuousCount=m/(cardGroup.type.cnt1+cardGroup.type.cnt2);
        }
        bool findFirstFigure;
        //cout<<"continuousCount="<<continuousCount<<endl;
        for(i=value+1;i<VALUECOUNT;i++){
            findFirstFigure=true;
            for(j=0;j<continuousCount;j++){ 
                if(cntFlag[i-j]<cardGroup.type.cnt1){
                    findFirstFigure=false;
                    break;
                }
            }
            if(findFirstFigure){
                ret.clear();
                int firstFigure=i;
                //cout<<"查找"<<cardGroup.type.cnt1<<"个"<<firstFigure+3<<endl;
                for(k=0,j=0;k<cardsHolded.size() &&j<continuousCount;k++){ 
                    if(cardsHolded[k]->value==firstFigure-j){
                        for(int kk=0;j>=0&&kk<cardGroup.type.cnt1;kk++){ 
                            ret.push_back(cardsHolded[k+kk]);
                        } 
                        j++; 
                    }
                } 
                if(cardGroup.type.cnt2>0){
                    int SecondFigures[5];
                    int SecondCount=continuousCount;
                    if(cardGroup.type.typeStr=="四带二")
                        SecondCount=2;
                    bool findSecondFigure=true;
                    for(j=0,k=-1;j<SecondCount &&findSecondFigure;j++){
                        findSecondFigure=false;
                        for(k++;k<VALUECOUNT;k++){
                            SecondFigures[j]=k;
                            if(cntFlag[k]>=cardGroup.type.cnt2 &&cntFlag[k]<cardGroup.type.cnt1){
                                findSecondFigure=true;
                                break;
                            }
                        }
                    }
                    if(findSecondFigure){
                        //cout<<"查找SecondFigure "<<cardGroup.type.cnt2<<"个"<<SecondFigures[0]+3<<endl;
                        //cout<<"SecondCount= "<<SecondCount<<endl;
                        //for(i=0;i<SecondCount;i++)cout<<"SecondFigures["<<i<<"]="<<SecondFigures[i]<<endl;
                        for(i=0;i<SecondCount;i++){ 
                            for(j=0;j<cardsHolded.size();){ 
                                if(cardsHolded[j]->value==SecondFigures[i]){
                                    for(k=0;k<cardGroup.type.cnt2;k++){
                                        //cout<<"添加"<<cardsHolded[j]->value+3<<endl;
                                        ret.push_back(cardsHolded[j+k]);
                                    }
                                    do{
                                        j++;
                                    }while(j<cardsHolded.size()&&cardsHolded[j]->value==SecondFigures[i]);
                                }else{
                                    j++;
                                } 
                            }
                        } 
                        return ret;
                    }//if(findSecondFigure) 
                }//end if(cardGroup.type.cnt2>0)
                else{
                    return ret;
                }
            }//end if(findFirstFigure)
        }//end for(i=value+1;i<VALUECOUNT;i++)
        ret.clear();
        //没牌打得过时查找有没有炸dan 
        if(typeStr!="炸dan"){
            for(i=cardsHolded.size()-1;i>=3;i--){
                if(cardsHolded[i]->value==cardsHolded[i-3]->value){
                    for(j=0;j<4;j++){
                        ret.push_back(cardsHolded[i-j]);
                    }
                    break;
                }
            }
        }
        return ret;   
    }//end vector<Card*> findCanBeatFrom()
};
LastCards* LastCards::lastCards = NULL;
 
class Player{
  public:
    string name;
    vector<Card*> cards;
    void arrange(){
        sort(cards.begin(),cards.end(),cmp);
    }
    void print(){
        cout<<this->name<<":\t";
        for(int i=0;i<cards.size();i++){
            cards[i]->print();
        }
        cout<<"["<<cards.size()<<"]\n";
    }
    vector<Card*> tip(){
        //提示功能,使自己最小一张连最长
        CardGroup ret;
        string temp;
        int j,k,m=cards.size();
        for(j=0;j<m;j++){
            temp="";
            for(k=j;k<m;k++){
                temp+=cards[k]->figure;
            }
            ret.init(temp,cards);
            if(ret.type.typeId!=ERROR){
                return ret.cards;
            }
        }
        ret.cards.clear();
        return ret.cards;
    }
    void chupai(CardGroup &cardGroup){
        //出牌 
        cout<<this->name<<":\t";
        cout<<cardGroup.type.typeStr<<' ';
        for(int i=0;i<cardGroup.cards.size();i++){
            cardGroup.cards[i]->print();
            this->cards.erase(find(this->cards.begin(),this->cards.end(),cardGroup.cards[i])); 
        }
        cout<<"\t["<<this->cards.size()<<"]\n";
        if(cardGroup.type.typeStr!="不出"){
            //记录到 LastCards 中 
            LastCards::inst()->player=this;
            LastCards::inst()->cardGroup.init(cardGroup.cards);
        }
    }
};
 
class Landlords{
    Player *player[PLAYERCOUNT];
    bool finished,youWin,landlordWin;
    int landlordIndex;
    Card *cards[CARDSCOUNT];
  public:
    Landlords(){
        int i,j,k;
        for(i=0;i<PLAYERCOUNT;i++){
            this->player[i]=new Player();
        }
        //54张牌初始化 
        for(k=i=0;i<14;i++){
            if(toFigure[i]==' '){
                continue;
            }
            for(COLOR color=eHEART;color<=eSPADE;color=(COLOR)(color+1)){
                this->cards[k++]=new Card(toFigure[i],color);
            }
        }
        this->cards[k++]=new Card('Y',eSPADE);
        this->cards[k]=new Card('Z',eHEART);
    }
    ~Landlords(){
        for(int i=0;i<PLAYERCOUNT;i++){
            delete this->player[i];
        }
        for(int i=0;i<CARDSCOUNT;i++){
            delete this->cards[i];
        }
    } 
    void init(){
        player[CURRENTPLAYER]->name="Bice";
        player[1]->name="玩家2";
        player[2]->name="玩家3";
        finished=false;
        youWin=false;
        landlordWin=false;
        //抢地主
        landlordIndex=ERROR; 
        while(landlordIndex==ERROR){
            srand((int)time(0));
            shuffle();
            landlordIndex=chooseLandlord();
        }
        cout<<player[landlordIndex]->name<<"\t成为地主\n\n";
        this->add3Cards();
        LastCards::inst()->player=player[landlordIndex];
    }
    void startGame(){
        string inputSrt;
        CardGroup inputCards;
        for(int iTurns=landlordIndex;!finished;iTurns++){
            if(iTurns>=PLAYERCOUNT){
                iTurns=0;
            }
            if(iTurns==CURRENTPLAYER){
                cout<<endl;
                player[iTurns]->print();
                cout<<"输入提示:Z=大王 Y=小王 0=10 输入可无序 例如:JKQ0A9\n请出牌:\t";
                do{
                    cin>>inputSrt;
                    inputCards.init(inputSrt,player[iTurns]->cards);
                }while(check(&inputCards)==false);
            }else{
                if(player[iTurns]==LastCards::inst()->player){
                    //若是上次出牌的是自己,启用提示功能 
                    inputCards.init(player[iTurns]->tip());
                }else{
                    //查找能打得过上家的牌 
                    inputCards.init(LastCards::inst()->findCanBeatFrom(player[iTurns]->cards));
                }
            }
            player[iTurns]->chupai(inputCards);//出牌 
            
            if(player[iTurns]->cards.size()==0){
                //玩家手中没牌了,游戏结束 
                finished=true;
                landlordWin=iTurns==landlordIndex;
                if(landlordWin){
                    youWin=landlordIndex==CURRENTPLAYER;
                }else{
                    youWin=landlordIndex!=CURRENTPLAYER;
                }
            }
        }
        cout<<"\n_________________________ "<<(youWin?"You Win!":"You Lose!")<<" _________________________\n\n";
    }
    void add3Cards(){
        cout<<"地主3张牌:\t";
        for(int i=PLAYERCOUNT*17;i<CARDSCOUNT;i++){
            this->cards[i]->print();
            player[landlordIndex]->cards.push_back(cards[i]);
        }
        cout<<endl;
        player[landlordIndex]->arrange();
    }
    int chooseLandlord(){
        cout<<"\n_________________________ 抢地主 _________________________\n\n";
        int first=-1,last,cnt=0,i,j=rand()%PLAYERCOUNT;
        bool decision;
        for(i=0;i<PLAYERCOUNT;i++,j==2?j=0:j++){
            if(j==CURRENTPLAYER){
                decision=makeChoice("是否抢地主?(Y=抢/N=不抢):");
            }else{ 
                decision=rand()%2;
            }
            if(decision){
                cnt++;
                last=j;
                if(first==-1){
                    first=j;
                }
                cout<<this->player[j]->name<<"\t抢地主\n";
            }else{
                cout<<this->player[j]->name<<"\t没有抢\n";
            }
        }
        if(cnt==0){
            cout<<"没人抢,重新发牌\n";
            return ERROR;
        }
        if(cnt==1){
            //第一轮只有一人抢地主 
            return first;
        }
        else{
            //最后一次争抢 
            if(first==CURRENTPLAYER){
                decision=makeChoice("是否抢地主?(Y=抢/N=不抢):");
            }else{
                decision=rand()%2;
            }
            if(decision){
                cout<<this->player[first]->name<<"\t抢地主\n";
                return first;
            }else{
                cout<<this->player[first]->name<<"\t没有抢\n";
                return last;
            }
        }
    }
    void shuffle(){
        int i,j,k;    
        //洗牌 
        for(i=0;i<CARDSCOUNT;i++){
            swap(this->cards[i],this->cards[rand()%CARDSCOUNT]);
        }
        
        //分牌 
        for(k=i=0;i<PLAYERCOUNT;i++){
            this->player[i]->cards.clear();
            for(j=0;j<17;j++){
                this->player[i]->cards.push_back(this->cards[k++]);
            }
            this->player[i]->arrange();//整理 
            this->player[i]->print();
        }
    }
    bool check(CardGroup *cardGroup){
        if(cardGroup->type.typeId==ERROR){
            cout<<"出牌错误,重新输入\n";
            return false;
        }else if(cardGroup->type.typeStr=="不出"){
            return true;
        }else if(LastCards::inst()->player!=player[CURRENTPLAYER]&&!cardGroup->isCanBeat(LastCards::inst()->cardGroup)){
            cout<<"打不过,重新输入\n";
            return false;
        }else{
            return true;
        }
    }
};
 
int main(){
    Landlords *landlords=new Landlords();
    do{
        landlords->init();//发牌、抢地主 
        landlords->startGame();//游戏开始 
    }while(makeChoice("\n是否继续游戏?(Y=继续/N=结束): "));
    delete landlords;
    return 0;
}
 
bool makeChoice(string tip){
    cout<<tip;
    string input;
    cin>>input;
    return input=="Y"||input=="y";
}
 
bool cmp(Card* a,Card* b){
    //比较两张牌大小 
    if(a->value==b->value){
        return a->color>b->color;
    }else{
        return a->value>b->value;
    }
}

4,取火柴

#include <iostream>
#include <windows.h>
#include <cstdlib>
#include <time.h>
using namespace std;
int main(){
    MessageBox(NULL,"游戏规则:\n1.每次只能取1~4根火柴\n2.取到最后一根为败","游戏规则",MB_OK);
    srand(time(0));
    int n=rand()%49+1;
    while(n>0){
        cout << "目前还有火柴" << n << "根\n";
        cout << "=============================\n";
        cout << "你想拿走多少根火柴:";
        int x;
        cin >> x;
        if(x<1||x>4){
            cout << "你犯规了,you lose!!!\n";
            system("pause");
            exit(3322234);
        }
        n-=x;
        if(n<=0){
            cout << "你拿了最后一根!!you lose!!!\n";
            system("pause");
            exit(2356487);
        }
        int x2=rand()%4+1;
        n-=x2;
        cout << "电脑想拿走" << x2 << "根火柴\n";
        cout << "============================\n";
    }
    cout << "you win!!!^_^\n";
    system("pause");
    return 0;
}

5,迷宫

#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include <time.h>
#define Height 25 //迷宫的高度,必须为奇数
#define Width 25 //迷宫的宽度,必须为奇数
#define Wall 1
#define Road 0
#define Start 2
#define End 3
#define Esc 5
#define Up 1
#define Down 2
#define Left 3
#define Right 4
int map[Height+2][Width+2];
void gotoxy(int x,int y) //移动坐标
{
COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord );
}
void hidden()//隐藏光标
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hOut,&cci);
cci.bVisible=0;//赋1为显示,赋0为隐藏
SetConsoleCursorInfo(hOut,&cci);
}
void create(int x,int y) //随机生成迷
{
int c[4][2]={0,1,1,0,0,-1,-1,0}; //四个方向
int i,j,t;
//将方向打乱
for(i=0;i<4;i++)
{
j=rand()%4;
t=c[i][0];c[i][0]=c[j][0];c[j][0]=t;
t=c[i][1];c[i][1]=c[j][1];c[j][1]=t;
}
map[x][y]=Road;
for(i=0;i<4;i++)
if(map[x+2*c[i][0]][y+2*c[i][1]]==Wall)
{
map[x+c[i][0]][y+c[i][1]]=Road;
create(x+2*c[i][0],y+2*c[i][1]);
}
}
int get_key() //接收按键
{
char c;
while(c=getch())
{
if(c==27) return Esc; //Esc
if(c!=-32)continue;
c=getch();
if(c==72) return Up; //上
if(c==80) return Down; //下
if(c==75) return Left; //左
if(c==77) return Right; //右
}
return 0;
}
void paint(int x,int y) //画迷宫
{
gotoxy(2*y-2,x-1);
switch(map[x][y])
{
case Start:
printf("入");break; //画入口
case End:
printf("出");break; //画出口
case Wall:
printf("▇");break; //画墙
case Road:
printf(" ");break; //画路
}
}
void game()
{
int x=2,y=1; //玩家当前位置,刚开始在入口处
int c; //用来接收按键
while(1)
{
gotoxy(2*y-2,x-1);
printf("●"); //画出玩家当前位置
if(map[x][y]==End) //判断是否到达出口
{
gotoxy(30,24);
printf("到达终点,按任意键结束");
getch();
break;
}
c=get_key();
if(c==Esc)
{
gotoxy(0,24);
break;
}
switch(c)
{
case Up: //向上走
if(map[x-1][y]!=Wall)
{
paint(x,y);
x--;
}
break;
case Down: //向下走
if(map[x+1][y]!=Wall)
{
paint(x,y);
x++;
}
break;
case Left: //向左走
if(map[x][y-1]!=Wall)
{
paint(x,y);
y--;
}
break;
case Right: //向右走
if(map[x][y+1]!=Wall)
{
paint(x,y);
y++;
}
break;
}
}
}
int main()
{
int i,j;
srand((unsigned)time(NULL)); //初始化随即种子
hidden(); //隐藏光标
for(i=0;i<=Height+1;i++)
for(j=0;j<=Width+1;j++)
if(i==0||i==Height+1||j==0||j==Width+1) //初始化迷宫
map[i][j]=Road;
else map[i][j]=Wall;
create(2*(rand()%(Height/2)+1),2*(rand()%(Width/2)+1)); //从随机一个点开始生成迷宫,该点行列都为偶数
for(i=0;i<=Height+1;i++) //边界处理
{
map[i][0]=Wall;
map[i][Width+1]=Wall;
}
for(j=0;j<=Width+1;j++) //边界处理
{
map[0][j]=Wall;
map[Height+1][j]=Wall;
}
map[2][1]=Start; //给定入口
map[Height-1][Width]=End; //给定出口
for(i=1;i<=Height;i++)
for(j=1;j<=Width;j++) //画出迷宫
paint(i,j);
game(); //开始游戏
getch();
return 0;
}

6,狼人杀

#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;
}

7,打怪小游戏2

​
#include<iostream> 
using namespace std;
int jb=0,a;
int rw1=10,rw2=40,rw3=70;
int lq1=0,lq2=0,lq3=0,lq4=0,lq5=0,lq6=0,lq7=0,lq8=0,lq9=0,rwlq=0;
int main()
{
	int xl=100,slzd=0,hd=0,yjx=0,yjd=0,yjj=0,sxs=0,dws=0,sx=0,wl=5,wl1=5,m,ful=5,lv=1,xg=20,mj=0,i=0,zxyjdxp,mx,jn,jrsd,bhgm,hsgm,mjdh,pd,ycjc=1;//血量,狩猎炸弹 ,核弹,增血药剂(小),增血药剂(大) ,增血药剂(巨),金币,升星石,顿悟石,武力,防御力,等级,小怪,觉醒者,遗迹守卫,魔晶,增血药剂大(小)瓶,任务,技能,进入商店(开门方法),百货购买,黑市购买,魔晶兑换,判断,吟唱加成伤害                      
	int c;//进入,任务循环 
	int zdbbwp,ffzf=0,rw2,lb=1,hqlb=0;//战斗背包里头要使用的物品 ,非法字符检测 ,任务2,礼包,获取礼包 
	//任务整合↓
	int swzjs=0,xyjs=0,mljs=0;//守望者击杀数量   腥猿击杀数量   魔灵击杀数量   
	string xm;//姓名
	cout<<"是否进入游戏    进入(输入1)   退出(输入2)"<<endl;
	cout<<"注意:请务必全屏"<<endl; 
	rw2=40;
	rw3=70;
	cin>>c; 
	if(c==2)
	{
		return 0;
	}
	cout<<"欢迎进入游戏"<<endl; 
	cout<<"给自己起一个昵称吧~"<<endl;
	cin>>xm;      
	cout<<"欢迎 "<<xm<<" 进入游戏"<<endl;
	while(i!=1)
	{
		ffzf = 0;
		if(lv>=10)
		{
			ycjc=10;
		}
		if(lv>=20)
		{
			ycjc=50;
		}
		if(lv>=40)
		{
			ycjc=100;
		}
		cout<<"欢迎 "<<xm<<" 来到小镇中心,查看公告请按11,查看属性请按10,查看背包请按9,冒险请按8,升星请按7,进入商店请按6,查看任务请按5,"<<endl;  
		cin>>a; 
		if(a==5){
			cout<<"欢迎来到任务界面"<<endl;
			if(lq1==0){
				cout<<"任务1"<<endl;
				cout<<"    击败10个守望者"<<endl;
				cout<<"    奖励500金币+30魔晶"<<endl;
				cout<<"    目前进度"<<"("<<swzjs<<"/"<<rw1<<")"<<endl;
				if(swzjs>=rw1)
				{
					cout<<"    已完成"<<endl; 
					cout<<"    未领取"<<endl;
					cout<<"    领取按1"<<endl; 
					cin>>rwlq;
					if(rwlq==1)
					{
						lq1=1;
						jb=jb+500;
						mj=mj+30;
						rwlq=0;
						cout<<"恭喜 "<<xm<<" 获得金币*500"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得魔晶*30"<<endl; 
					}
				}
			}
			if(lq2==0){
				cout<<"任务2"<<endl;
				cout<<"    击败10个腥猿"<<endl;
				cout<<"    奖励800金币+40魔晶"<<endl;
				cout<<"    目前进度"<<"("<<xyjs<<"/"<<rw1<<")"<<endl;
				if(xyjs>=rw1)
				{
					cout<<"    已完成"<<endl; 
					cout<<"    未领取"<<endl;
					cout<<"    领取按1"<<endl; 
					cin>>rwlq;
					if(rwlq==1)
					{
						lq2=1;
						jb=jb+800;
						mj=mj+40;
						rwlq=0;
						cout<<"恭喜 "<<xm<<" 获得金币*800"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得魔晶*40"<<endl; 
					}
				}
			}
			if(lq3==0){
				cout<<"任务3"<<endl;
				cout<<"    击败10个魔灵"<<endl;
				cout<<"    奖励1000金币+50魔晶+1瓶增血药剂(小)"<<endl;
				cout<<"    目前进度"<<"("<<mljs<<"/"<<rw1<<")"<<endl;
				if(mljs>=rw1)
				{
					cout<<"    已完成"<<endl; 
					cout<<"    未领取"<<endl;
					cout<<"    领取按1"<<endl; 
					cin>>rwlq;
					if(rwlq==1)
					{
						lq3=1;
						jb=jb+1000;
						mj=mj+50;
						yjx+=1; 
						rwlq=0;
						cout<<"恭喜 "<<xm<<" 获得金币*1000"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得魔晶*50"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得增血药剂(小)*1"<<endl; 
					}
				}
			}
			if(lq4==0){
				cout<<"任务4"<<endl;
				cout<<"    击败40个守望者"<<endl;
				cout<<"    奖励1000金币+50魔晶+1捆狩猎炸弹"<<endl;
				cout<<"    目前进度"<<"("<<swzjs<<"/"<<rw2<<")"<<endl;
				if(swzjs>=rw2)
				{
					cout<<"    已完成"<<endl; 
					cout<<"    未领取"<<endl;
					cout<<"    领取按1"<<endl; 
					cin>>rwlq;
					if(rwlq==1)
					{
						lq4=1;
						jb=jb+1000;
						mj=mj+50;
						rwlq=0;
						slzd+=1;
						cout<<"恭喜 "<<xm<<" 获得金币*1000"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得魔晶*50"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得狩猎炸弹*1"<<endl; 
					}
				}
			}
			if(lq5==0){
				cout<<"任务5"<<endl;
				cout<<"    击败40个腥猿"<<endl;
				cout<<"    奖励5000金币+100魔晶+3捆狩猎炸弹"<<endl;
				cout<<"    目前进度"<<"("<<xyjs<<"/"<<rw2<<")"<<endl;
				if(xyjs>=rw2)
				{
					cout<<"    已完成"<<endl; 
					cout<<"    未领取"<<endl;
					cout<<"    领取按1"<<endl; 
					cin>>rwlq;
					if(rwlq==1)
					{
						lq5=1;
						jb=jb+5000;
						mj=mj+100;
						slzd=slzd+3;
						rwlq=0;
						cout<<"恭喜 "<<xm<<" 获得金币*5000"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得魔晶*100"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得狩猎炸弹*3"<<endl; 
					}
				}
			}
			if(lq6==0){
				cout<<"任务6"<<endl;
				cout<<"    击败40个魔灵"<<endl;
				cout<<"    奖励10000金币+200魔晶+3瓶增血药剂(小)+1瓶增血药剂(大)"<<endl;
				cout<<"    目前进度"<<"("<<mljs<<"/"<<rw2<<")"<<endl;
				if(mljs>=rw2)
				{
					cout<<"    已完成"<<endl; 
					cout<<"    未领取"<<endl;
					cout<<"    领取按1"<<endl; 
					cin>>rwlq;
					if(rwlq==1)
					{
						lq6=1;
						jb=jb+10000;
						mj=mj+200;
						yjx=yjx+3;
						yjd+=1;
						rwlq=0;
						cout<<"恭喜 "<<xm<<" 获得金币*10000"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得魔晶*200"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得增血药剂(小)*3"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得增血药剂(大)*1"<<endl; 
					}
				}
			}
			if(lq7==0){
				cout<<"任务7"<<endl;
				cout<<"    击败70个守望者"<<endl;
				cout<<"    奖励5000金币+200魔晶+3捆狩猎炸弹"<<endl;
				cout<<"    目前进度"<<"("<<swzjs<<"/"<<rw3<<")"<<endl;
				if(swzjs>=rw3)
				{
					cout<<"    已完成"<<endl; 
					cout<<"    未领取"<<endl;
					cout<<"    领取按1"<<endl; 
					cin>>rwlq;
					if(rwlq==1)
					{
						lq7=1;
						jb=jb+5000;
						mj=mj+200;
						slzd=slzd+3;
						rwlq=0;
						cout<<"恭喜 "<<xm<<" 获得金币*5000"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得魔晶*200"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得狩猎炸弹*3"<<endl; 
					}
				}
			}
			if(lq8==0){
				cout<<"任务8"<<endl;
				cout<<"    击败70个腥猿"<<endl;
				cout<<"    奖励10000金币+400魔晶+5捆狩猎炸弹"<<endl;
				cout<<"    目前进度"<<"("<<xyjs<<"/"<<rw3<<")"<<endl;
				if(xyjs>=rw3)
				{
					cout<<"    已完成"<<endl; 
					cout<<"    未领取"<<endl;
					cout<<"    领取按1"<<endl; 
					cin>>rwlq;
					if(rwlq==1)
					{
						lq8=1;
						jb=jb+5000;
						mj=mj+100;
						rwlq=0;
						slzd=slzd+5;
						cout<<"恭喜 "<<xm<<" 获得金币*5000"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得魔晶*400"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得狩猎炸弹*5"<<endl; 
					}
				}
			}
			if(lq9==0){
				cout<<"任务9"<<endl;
				cout<<"    击败70个魔灵"<<endl;
				cout<<"    奖励20000金币+500魔晶+6瓶增血药剂(小)+2瓶增血药剂(大)+1瓶增血药剂(大)"<<endl;
				cout<<"    目前进度"<<"("<<mljs<<"/"<<rw3<<")"<<endl;
				if(mljs>=rw3)
				{
					cout<<"    已完成"<<endl; 
					cout<<"    未领取"<<endl;
					cout<<"    领取按1"<<endl; 
					cin>>rwlq;
					if(rwlq==1)
					{
						lq9=1;
						jb=jb+20000;
						mj=mj+500;
						yjx=yjx+6;
						yjd=yjd+2;
						yjj+=1;
						rwlq=0;
						cout<<"恭喜 "<<xm<<" 获得金币*10000"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得魔晶*200"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得增血药剂(小)*6"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得增血药剂(大)*2"<<endl; 
						cout<<"恭喜 "<<xm<<" 获得增血药剂(巨)*1"<<endl; 
					}
				}
			}
		}
		if(a==11)
		{
			ffzf = 1;
			cout<<"新版本1.5  作者ΜèΛɡ★☆
,电话:13811025267"<<endl; 
			cout<<"温馨提示:所有Bug已修复如有侵权,发现Bug请及时联系作者↑"<<endl; 
			cout<<"全屏游玩效果提升"<<endl; 
			cout<<"任务完成并领取后将会自动移除没有显示"<<endl; 
			cout<<"任务开启,击杀一定数量怪物会有奖励,在任务界面领取"<<endl; 
			if(lb==1)
			{
				cout<<"目前礼包:新手礼包(豪华)  未领取"<<endl;
				cout<<"领取(1)  退出(2)"<<endl;
				cin>>hqlb;
				if(hqlb==1)
				{
					cout<<"领取成功"<<endl;
					cout<<"恭喜 "<<xm<<" 获得金币*500"<<endl; 
					jb=jb+500;
					cout<<"恭喜 "<<xm<<" 获得魔晶*50"<<endl; 
					mj=mj+50;
					cout<<"恭喜 "<<xm<<" 获得狩猎炸弹*3"<<endl; 
					slzd=slzd+3;
					cout<<"恭喜 "<<xm<<" 获得增血药剂(大)*1"<<endl; 
					yjd = yjd+1;
					cout<<"恭喜 "<<xm<<" 获得增血药剂(小)*5"<<endl; 
					yjx = yjx+5;
					lb=lb-1; 
				}
			}
		} 
		if(a==10)
		{
			ffzf = 1;
			cout<<xm<<endl; 
			cout<<"lv:"<<lv<<endl; 
			cout<<"血量为:"<<xl<<endl; 
			cout<<"武力:"<<wl<<endl; 
			cout<<"防御力:"<<wl<<endl; 
		} 
		if(a==9)
		{
			ffzf = 1;
			cout<<"狩猎炸弹:*"<<slzd<<"个"<<endl; 
			cout<<"核弹:*"<<hd<<"个"<<endl; 
			cout<<"增血药剂(小):*"<<yjx<<"瓶"<<endl; 
			cout<<"增血药剂(大):*"<<yjd<<"瓶"<<endl; 
			cout<<"增血药剂(巨):*"<<yjj<<"瓶"<<endl; 
			cout<<"金币:*"<<jb<<"个"<<endl; 
			cout<<"魔晶:*"<<mj<<"颗"<<endl; 
			cout<<"如想使用增血药剂(大)请按1,如想使用增血药剂(小)请按2,如想使用增血药剂(巨)请按3,退出按4"<<endl;
			cin>>zxyjdxp;
			if(zxyjdxp==1)
			{
				if(yjd>=1)
				{
					xl=xl+40;
					cout<<"使用成功  血量 + 40  现血量:"<< xl<<endl;
					yjd=yjd-1;
				}
				else
				{
					cout<<"你没有该药剂了"<<endl; 
				}
			}
			if(zxyjdxp==2)
			{
				if(yjx>=1)
				{
					xl=xl+20;
					cout<<"使用成功  血量 + 20  现血量:"<< xl<<endl;
					yjx=yjx-1;
				}
				else
				{
					cout<<"你没有该药剂了"<<endl; 
				}
			} 
			if(zxyjdxp==3)
			{
				if(yjj>=1)
				{
					xl=xl+120;
					cout<<"使用成功  血量 + 120  现血量:"<< xl<<endl;
					yjj=yjj-1;
				}
				else
				{
					cout<<"你没有该药剂了"<<endl; 
				}
			} 
		}
		if(a==7)
		{
			ffzf = 1;
			cout<<"你的金币为"<<jb<<endl; 
			cout<<"当前等级为lv"<<lv<<endl;
			cout<<"lv15以内升星将会减少500金币"<<endl; 
			cout<<"lv25以内升星将会减少1000金币"<<endl; 
			cout<<"lv40以内升星将会减少3000金币"<<endl;
			cout<<"确认升星请按1,退出按2"<<endl;
			cin>>sx;
			if(sx==1)
			{
				if(lv<=15)
				{
					if(jb>=500)
					{
						jb=jb-500;
						lv++;
						cout<<"升级成功!!!获得金币*100!!!获得魔晶*10  当前等级为  lv:"<<lv<<endl;
						wl=wl+wl/5;
						ful=ful+ful/5;
						xl=xl+5;
						jb=jb+100;
						mj=mj+10;
					}
				}
				else
				{
					if(lv<=25)
					{
						if(jb>=1000)
						{
							jb=jb-1000;
							lv++;
							cout<<"升级成功!!!获得金币*200!!!获得魔晶*20  当前等级为  lv:"<<lv<<endl;
							wl=wl+lv;
							ful=ful+lv;
							xl=xl+10;
							jb=jb+200;
							mj=mj+20;
						}
					}
					else
					{
						if(lv<=40||lv>=40)
						{
							if(jb>=3000)
							{
								jb=jb-1000;
								lv++;
								cout<<"升级成功!!!获得金币*200!!!获得魔晶*20  当前等级为  lv:"<<lv<<endl;
								wl=wl+wl/5;
								ful=ful+ful/5;
								xl=xl+10;
								jb=jb+200;
								mj=mj+20;
							}
							else{
								cout<<"金币不够了"<<endl;
							}
						}
					}
				}
			} 
		}
		if(a==8)
		{
			ffzf = 1;
			if(xl>=5)
			{
				cout<<"平地高原(按1)lv0解锁   敌人介绍:守望者,一种器械,血量40,伤害5。    建议;用狩猎炸弹可以直接秒杀,新手期可以在这里刷级"<<endl;                     
				cout<<"高山地脉(按2)lv10解锁   敌人介绍:腥猿,一种魔物,血量200,伤害20。    建议;不到15级后去结果可想而知"<<endl;
				cout<<"林间沼泽(按3)lv20解锁   敌人介绍:魔灵,一种魔物,血量400,伤害80。    建议;魔灵会吸取你的50血量,灌满药再去"<<endl;
				cout<<"兽潮(按4)lv40解锁   敌人介绍:以上三种魔物    目前开发中,敬请期待"<<endl;
				cin>>mx;//10lv20lv40lv 
				if(mx == 2)
				{
					cout<<"Lv10解锁"<<endl; 
					if(lv >= 10)
					{
						cout<<"满足需求,是否挑战?"<<endl;
						cout<<"是(1)    还是在看看吧(2)"<<endl;
						cin>>rw2;
						if(rw2==1) 
						{
							cout<<"野生的 腥猿 出现了!"<<endl; 
							xg=200;
							wl1=wl;
							cout<<"战斗开始!!!"<<endl; 
							while(xg> 0)
							{
							
								cout<<"技能如下:撞击(1)  手刀(2)  吟唱(3)  打开战斗背包(4)"<<endl;
								cin>>jn;
								if(jn==1){
									xg=xg-wl;
									cout<<"腥猿-"<<wl<<"  血量:"<<xg<<endl;
									if(xg>0)
									{
										xl=xl-20;
										cout<<" 腥猿 使用了 蛮荒之力 | 你受到的伤害:20"<<"你的血量为"<< xl-20<<endl;
									}
									pd=0;
								}
								if(jn==2){
									xg=xg-wl;
									cout<<"腥猿-"<<wl<<"  血量:"<<xg<<endl;
									if(xg>0)
									{
										xl=xl-20;
										cout<<" 腥猿 使用了 撞击 | 你受到的伤害:20"<<"你的血量为"<< xl-20<<endl;
									}
									pd=0;
								}
								if(jn==3){
									cout<<"你的攻击力,命中率提高"<<endl;
									wl=wl+ycjc;
									if(xg>0)
									{
										xl=xl-20;
										cout<<" 腥猿 使用了 撞击 | 你受到的伤害:20"<<"你的血量为"<< xl-20<<endl;
										pd=1;
									}
								}
								if(pd!=1)
								{
									wl=wl1;
								}
								if(jn==4)
								{
									cout<<"狩猎炸弹:*"<<slzd<<"个"<<endl; 
									cout<<"核弹:*"<<hd<<"个"<<endl; 
									cout<<"增血药剂(小):*"<<yjx<<"瓶"<<endl; 
									cout<<"增血药剂(大):*"<<yjd<<"瓶"<<endl; 
									cout<<"增血药剂(巨):*"<<yjj<<"瓶"<<endl; 
									cout<<"使用增血药剂(大)请按1,使用增血药剂(小)请按2,使用增血药剂(巨)请按3,使用狩猎炸弹请按4,使用核弹请按5,退出按任意键"<<endl;
									cin>>zdbbwp;
									if(zdbbwp==1)
									{
										if(yjd>=1)
										{	
											xl=xl+40;
											cout<<"使用成功  血量 + 40  现血量:"<< xl<<endl;
											yjd=yjd-1;
										}
										else
										{
											cout<<"你没有该物品了"<<endl; 
										}
									}
									if(zdbbwp==2)
									{
										if(yjx>=1)
										{
											xl=xl+20;
											cout<<"使用成功  血量 + 20  现血量:"<< xl<<endl;
											yjx=yjx-1;
										}
										else
										{
											cout<<"你没有该物品了"<<endl; 
										}
									} 
									if(zdbbwp==3)
									{
										if(yjj>=1)
										{
											xl=xl+120;
											cout<<"使用成功  血量 + 120  现血量:"<< xl<<endl;
											yjj=yjj-1;
										}
										else
										{	
											cout<<"你没有该物品了"<<endl; 
										}
									} 
									if(zdbbwp==4)
									{
										if(slzd>=1)
										{
											xg=xg-40;
											cout<<"使用成功  腥猿血量 -40  腥猿血量:"<<xg<<endl;
											slzd=slzd-1;
										}
										else
										{
											cout<<"你没有该物品了"<<endl; 
										}	
									} 
									if(zdbbwp==5)
									{	
										if(hd>=1)
										{
											xg=xg-200;
											cout<<"使用成功  腥猿血量 -200  腥猿血量:"<<xg<<endl;
											hd=hd-1;
										}
										else
										{
											cout<<"你没有该物品了"<<endl; 
										}
									} 
								}							
							}
							if(xl>0)
							{
								cout<<"战斗结束     金币+500     魔晶+40"<<endl;
								jb=jb+500;
								mj=mj+40;
								xyjs+=1;
							}
							else
							{
								cout<<"你失败了  可以通过以下变强↓" <<endl; 
								cout<<"①可以通过升星来提升实力" <<endl; 
								cout<<"②用增血药剂把自己喂满在战斗(血量可叠加)" <<endl; 
								cout<<"③到 黑市 和 魔晶交易所 可以淘到不少好东西" <<endl; 
							}
						}
					}
				}
				if(mx == 3)
				{
					cout<<"Lv20解锁"<<endl; 
					if(lv >= 20)
					{
						cout<<"满足需求,是否挑战?"<<endl;
						cout<<"是(1)    还是在看看吧(2)"<<endl;
						cin>>rw2;
						if(rw2==1) 
						{
							cout<<"野生的 魔灵 出现了!"<<endl; 
							xg=400;
							wl1=wl;
							cout<<"战斗开始!!!"<<endl; 
							while(xg> 0)
							{
							
								cout<<"技能如下:撞击(1)  手刀(2)  吟唱(3)  打开战斗背包(4)"<<endl;
								cin>>jn;
								if(jn==1){
									xg=xg-wl;
									cout<<"魔灵-"<<wl<<"  血量:"<<xg<<endl;
									if(xg>0)
									{
										xl=xl-80;
										cout<<" 魔灵 使用了 噬魂 | 你受到的伤害为80"<<"你的血量为"<<xl-80<<endl;
										xg=xg+50;
										cout<<" 魔灵 使用了 噬魂 | 吸收的伤害:50"<<"魔灵的血量 +50"<<endl;
									}
									pd=0;
								}
								if(jn==2){
									xg=xg-wl;
									cout<<"魔灵-"<<wl<<"  血量:"<<xg<<endl;
									if(xg>0)
									{
										xl=xl-80;
										cout<<" 魔灵 使用了 噬魂 | 你受到的伤害为80"<<"你的血量为"<<xl<<endl;
										xg=xg+50;
										cout<<" 魔灵 使用了 噬魂 | 吸收的伤害:50"<<"魔灵的血量 +50"<<endl;
									}
									pd=0;
								}
								if(jn==3){
									cout<<"你的攻击力,命中率提高"<<endl;
									wl=wl+ycjc;
									if(xg>0)
									{
										xl=xl-80;
										cout<<" 魔灵 使用了 噬魂 | 你受到的伤害为80"<<"你的血量为"<< xl-80<<endl;
										xg=xg+50;
										cout<<" 魔灵 使用了 噬魂 | 吸收的伤害:50"<<"魔灵的血量 +50"<<endl;
										pd=1;
									}
								}
								if(pd!=1)
								{
									wl=wl1;
								}
								if(jn==4)
								{
									cout<<"狩猎炸弹:*"<<slzd<<"个"<<endl; 
									cout<<"核弹:*"<<hd<<"个"<<endl; 
									cout<<"增血药剂(小):*"<<yjx<<"瓶"<<endl; 
									cout<<"增血药剂(大):*"<<yjd<<"瓶"<<endl; 
									cout<<"增血药剂(巨):*"<<yjj<<"瓶"<<endl; 
									cout<<"使用增血药剂(大)请按1,使用增血药剂(小)请按2,使用增血药剂(巨)请按3,使用狩猎炸弹请按4,使用核弹请按5,退出按任意键"<<endl;
									cin>>zdbbwp;
									if(zdbbwp==1)
									{
										if(yjd>=1)
										{	
											xl=xl+40;
											cout<<"使用成功  血量 + 40  现血量:"<< xl<<endl;
											yjd=yjd-1;
										}
										else
										{
											cout<<"你没有该物品了"<<endl; 
										}
									}
									if(zdbbwp==2)
									{
										if(yjx>=1)
										{
											xl=xl+20;
											cout<<"使用成功  血量 + 20  现血量:"<< xl<<endl;
											yjx=yjx-1;
										}
										else
										{
											cout<<"你没有该物品了"<<endl; 
										}
									} 
									if(zdbbwp==3)
									{
										if(yjj>=1)
										{
											xl=xl+120;
											cout<<"使用成功  血量 + 120  现血量:"<< xl<<endl;
											yjj=yjj-1;
										}
										else
										{	
											cout<<"你没有该物品了"<<endl; 
										}
									} 
									if(zdbbwp==4)
									{
										if(slzd>=1)
										{
											xg=xg-40;
											cout<<"使用成功  魔灵血量 -40  魔灵血量:"<<xg<<endl;
											slzd=slzd-1;
										}
										else
										{
											cout<<"你没有该物品了"<<endl; 
										}	
									} 
									if(zdbbwp==5)
									{	
										if(hd>=1)
										{
											xg=xg-200;
											cout<<"使用成功  腥猿血量 -200  腥猿血量:"<<xg<<endl;
											hd=hd-1;
										}
										else
										{
											cout<<"你没有该物品了"<<endl; 
										}
									} 
								}							
							}
							if(xl>0)
							{
								cout<<"战斗结束     金币+500     魔晶+40"<<endl;
								jb=jb+500;
								mj=mj+40;
								mljs+=1;
							}
							else
							{
								cout<<"你失败了  可以通过以下变强↓" <<endl; 
								cout<<"①可以通过升星来提升实力" <<endl; 
								cout<<"②用增血药剂把自己喂满在战斗(血量可叠加)" <<endl; 
								cout<<"③到 黑市 和 魔晶交易所 可以淘到不少好东西" <<endl; 
							}
						}
					}
				}
				if(mx == 4)
				{
					cout<<"敬请期待..."<<endl; 
				}
				if(mx==1)
				{
					cout<<"野生的 守望者 出现了!"<<endl; 
					xg=40;
					wl1=wl;
					cout<<"战斗开始!!!"<<endl; 
					while(xg> 0)
					{
						
						cout<<"技能如下:撞击(1)  手刀(2)  吟唱(3)  打开战斗背包(4)"<<endl;
						cin>>jn;
						if(jn==1){
							xg=xg-wl;
							cout<<"守望者-"<<wl<<"  血量:"<<xg<<endl;
							if(xg>0)
							{
								xl=xl-5;
								cout<<" 守望者 使用了 连弩射击 | 你受到的伤害:5"<<"你的血量为"<< xl-5<<endl;
							}
							pd=0;
						}
						if(jn==2){
							xg=xg-wl;
							cout<<"守望者-"<<wl<<"  血量:"<<xg<<endl;
							if(xg>0)
							{
								xl=xl-5;
								cout<<" 守望者 使用了 连弩射击 | 你受到的伤害:5"<<"你的血量为"<< xl-5<<endl;
							}
							pd=0;
						}
						if(jn==3){
							cout<<"你的攻击力,命中率提高"<<endl;
							wl=wl+ycjc;
							if(xg>0)
							{
								xl=xl-5;
								cout<<" 守望者 使用了 连弩射击 | 你受到的伤害:5"<<"你的血量为"<< xl-5<<endl;
								pd=1;
							}
						}
						if(pd!=1)
						{
							wl=wl1;
						}
						if(jn==4)
						{
							cout<<"狩猎炸弹:*"<<slzd<<"个"<<endl; 
							cout<<"核弹:*"<<hd<<"个"<<endl; 
							cout<<"增血药剂(小):*"<<yjx<<"瓶"<<endl; 
							cout<<"增血药剂(大):*"<<yjd<<"瓶"<<endl; 
							cout<<"增血药剂(巨):*"<<yjj<<"瓶"<<endl; 
							cout<<"使用增血药剂(大)请按1,使用增血药剂(小)请按2,使用增血药剂(巨)请按3,使用狩猎炸弹请按4,使用核弹请按5,退出按任意键"<<endl;
							cin>>zdbbwp;
							if(zdbbwp==1)
							{
								if(yjd>=1)
								{
									xl=xl+40;
									cout<<"使用成功  血量 + 40  现血量:"<< xl<<endl;
									yjd=yjd-1;
								}
								else
								{
									cout<<"你没有该物品了"<<endl; 
								}
							}
							if(zdbbwp==2)
							{
								if(yjx>=1)
								{
									xl=xl+20;
									cout<<"使用成功  血量 + 20  现血量:"<< xl<<endl;
									yjx=yjx-1;
								}
								else
								{
									cout<<"你没有该物品了"<<endl; 
								}
							} 
							if(zdbbwp==3)
							{
								if(yjj>=1)
								{
									xl=xl+120;
									cout<<"使用成功  血量 + 120  现血量:"<< xl<<endl;
									yjj=yjj-1;
								}
								else
								{
									cout<<"你没有该物品了"<<endl; 
								}
							} 
							if(zdbbwp==4)
							{
								if(slzd>=1)
								{
									xg=xg-40;
									cout<<"使用成功  守望者血量 -40  守望者血量:"<<xg<<endl;
									slzd=slzd-1;
								}
								else
								{
									cout<<"你没有该物品了"<<endl; 
								}
							} 
							if(zdbbwp==5)
							{
								if(hd>=1)
								{
									xg=xg-200;
									cout<<"使用成功  守望者血量 -200  守望者血量:"<<xg<<endl;
									hd=hd-1;
								}
								else
								{
									cout<<"你没有该物品了"<<endl; 
								}
							} 
						}
						
					}
					if(xl>0)
					{
						cout<<"战斗结束     金币+300     魔晶+10"<<endl;
						jb=jb+300;
						mj=mj+10;
						swzjs+=1;
					}
					else
					{
						cout<<"你失败了  可以通过以下变强↓" <<endl; 
						cout<<"①可以通过升星来提升实力" <<endl; 
						cout<<"②用增血药剂把自己喂满在战斗(血量可叠加)" <<endl; 
						cout<<"③到 黑市 和 魔晶交易所 可以淘到不少好东西" <<endl; 
					}
				}
			}
			else
			{
				cout<<"你没有血量了"<<endl;
			}
		}
		if(a==6)
		{
			ffzf = 1;
			cout<<"请选择你要进入的商店:"<<endl; 
			cout<<"百货大楼(1)  黑市(2)  魔晶交易所(3)"<<endl; 
			cin>>jrsd;
			if(jrsd==1)
			{
				cout<<"巨型增血药剂 1500金币一桶(购买按1)   大型增血药剂1000金币(购买按2)   小型增血药剂600金币(购买按3)   核弹100000金币(购买按4)    500金币可换50魔晶(购买按5)     狩猎炸弹1000金币(购买按6)退出按9"<<endl;
				cin>>bhgm;
				if(bhgm==1)
				{
					if(jb>=1500)
					{
						jb=jb-1500;
						cout<<"恭喜 "<<xm<<" 获得 巨型增血药剂一桶"<<endl;
						yjj=yjj + 1;
					} 
					else
					{
						cout<<"金币不够了!"<<endl; 
					}
				}
				if(bhgm==2)
				{
					if(jb>=1000)
					{
						jb=jb-1000;
						cout<<"恭喜 "<<xm<<" 获得 大型增血药剂一桶"<<endl;
						yjd=yjd + 1;
					} 
					else
					{
						cout<<"金币不够了!"<<endl; 
					}
				}
				if(bhgm==3)
				{
					if(jb>=600)
					{
						jb=jb-600;
						cout<<"恭喜 "<<xm<<" 获得 小型增血药剂一瓶"<<endl;
						yjx=yjx + 1;
					} 
					else
					{
						cout<<"金币不够了!"<<endl; 
					}
				}
				if(bhgm==5)
				{
					if(jb>=500)
					{
						jb=jb-500;
						mj=mj+50; 
						cout<<"恭喜 "<<xm<<" 获得 魔晶*50"<<endl;
					} 
					else
					{
						cout<<"金币不够了!"<<endl; 
					}
				}
				if(bhgm==6)
				{
					if(jb>=1000)
					{
						jb=jb-1000;
						slzd=slzd+50; 
						cout<<"恭喜 "<<xm<<" 获得 狩猎炸弹*1"<<endl;
					} 
					else
					{
						cout<<"金币不够了!"<<endl; 
					}
				}
			}
			if(jrsd==2)
			{
				cout<<"欢迎来到 黑市"<<endl; 
				cout<<"巨型增血药剂 1200金币一桶(8折)(购买按1)   大型增血药剂900金币(9折)(购买按2)   小型增血药剂600金币(购买按3)   核弹95000金币(九五折)(购买按4)   400金币换50魔晶(购买按5)   狩猎炸弹800金币(八折)  退出按9"<<endl;   
				cout<<"你拥有的金币为"<<jb<<endl; 
				cin>>hsgm;
				if(hsgm==1)
				{
					if(jb>=1200)
					{
						jb=jb-1200;
						cout<<"恭喜 "<<xm<<" 获得 巨型增血药剂一桶"<<endl;
						yjj=yjj + 1;
					} 
					else
					{
						cout<<"金币不够了!"<<endl; 
					}
				}
				if(hsgm==2)
				{
					if(jb>=900)
					{
						jb=jb-900;
						cout<<"恭喜 "<<xm<<" 获得 大型增血药剂一桶"<<endl;
						yjd=yjd + 1;
					} 
					else
					{
						cout<<"金币不够了!"<<endl; 
					}
				}
				if(hsgm==3)
				{
					if(jb>=600)
					{
						jb=jb-600;
						cout<<"恭喜 "<<xm<<" 获得 小型增血药剂一瓶"<<endl;
						yjx=yjx + 1;
					} 
					else
					{
						cout<<"金币不够了!"<<endl; 
					}
				}
				if(hsgm==4)
				{
					if(jb>=100000)
					{
						jb=jb-100000;
						cout<<"恭喜 "<<xm<<" 获得 核弹一枚"<<endl;
						hd=hd + 1;
					} 
					else
					{
						cout<<"金币不够了!"<<endl; 
					}
				}
				if(hsgm==5)
				{
					if(jb>=400)
					{
						jb=jb-400;
						cout<<"恭喜 "<<xm<<" 获得 50魔晶"<<endl;
						mj=mj + 50;
					} 
					else
					{
						cout<<"金币不够了!"<<endl; 
					}
				}
			}
			if(jrsd==3)
			{
				cout<<"魔晶交易所欢迎您的到来"<<endl; 
				cout<<"巨型增血药剂 200魔晶一桶(购买按1)   大型增血药剂140魔晶(9折)(购买按2)   小型增血药剂100魔晶(购买按3)   核弹10000魔晶(购买按4)  20魔晶换100金币(购买按5)   50魔晶换300金币(购买按6)    退出按9"<<endl;                      
				cout<<"你拥有的魔晶为"<<mj<<endl; 
				cin>>mjdh;
				if(mjdh==1)
				{
					if(mj>=200)
					{
						mj=mj-200;
						cout<<"恭喜 "<<xm<<" 兑换 巨型增血药剂一桶"<<endl;
						yjj=yjj + 1;
					} 
					else
					{
						cout<<"魔晶不够了!"<<endl; 
					}
				}
				if(mjdh==2)
				{
					if(mj>=140)
					{
						mj=mj-140;
						cout<<"恭喜 "<<xm<<" 兑换 大型增血药剂一桶"<<endl;
						yjd=yjd + 1;
					} 
					else
					{
						cout<<"魔晶不够了!"<<endl; 
					}
				}
				if(mjdh==3)
				{
					if(mj>=100)
					{
						mj=mj-100;
						cout<<"恭喜 "<<xm<<" 兑换 小型增血药剂一瓶"<<endl;
						yjx=yjx + 1;
					} 
					else
					{
						cout<<"魔晶不够了!"<<endl; 
					}
				}
				if(mjdh==4)
				{
					if(mj>=10000)
					{
						mj=mj-10000;
						cout<<"恭喜 "<<xm<<" 兑换 核弹一枚"<<endl;
						hd=hd + 1;
					} 
					else
					{
						cout<<"魔晶不够了!"<<endl; 
					}
				}
				if(mjdh==5)
				{
					if(mj>=20)
					{
						mj=mj-20;
						cout<<"恭喜 "<<xm<<" 兑换 金币*100"<<endl;
						jb=jb+100; 
					} 
					else
					{
						cout<<"魔晶不够了!"<<endl; 
					}
				}
				if(mjdh==6)
				{
					if(mj>=50)
					{
						mj=mj-50;
						cout<<"恭喜 "<<xm<<" 兑换 金币*300"<<endl;
						jb=jb+300;
					} 
					else
					{
						cout<<"魔晶不够了!"<<endl; 
					}
				}
			}
		}
		else
		{
			if(ffzf==0){
				cout<<"非法字符(可能由于Bug原因导致)"<<endl;
			} 
		}
	}
	return 0;
}

​

8,推箱子

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
 
int  map[2][7][8] =
{
	//0:空的 1:■ :墙
	//3:☆ 4:★  //目的地和箱子
	//5:※		  //人
	//7:⊙		  //目的(3)和箱子(4)在一起
	//8:※		  //人(5)和目的(3)在一起
	//为让多种情况使用一种算法
 
	{
	1, 1, 1, 1, 1, 1, 1, 1,
	1, 0, 0, 0, 0, 0, 0, 1,
	1, 3, 1, 0, 1, 1, 3, 1,
	1, 4, 0, 0, 4, 0, 3, 1,
	1, 0, 1, 0, 1, 1, 4, 1,
	1, 0, 0, 5, 0, 0, 0, 1,
	1, 1, 1, 1, 1, 1, 1, 1
	},
	{
		1, 1, 1, 1, 1, 1, 1, 1,
		1, 0, 0, 0, 0, 0, 0, 1,
		1, 3, 1, 0, 1, 1, 3, 1,
		1, 3, 4, 5, 4, 0, 3, 1,
		1, 4, 1, 0, 1, 1, 4, 1,
		1, 0, 0, 0, 0, 0, 0, 1,
		1, 1, 1, 1, 1, 1, 1, 1
	}
};
int cas = 0;	//为0表示第一关
//记录每一关的箱子数 或者是项目和目的在一起的总数
int boxSum[2] = {3,4};
//地图绘图
void drawMap()
{
	for (int i = 0; i < 7; i++)
	{
		for (int j = 0; j < 8; j++)
		{
			if (j == 0)
				printf("\t\t");
			switch (map[cas][i][j])
			{
				//	//0:空的 1:■ :墙
			case 0:
				printf("  ");
				break;
			case 1:
				printf("■");
				break;
				//3:☆ 4:★  //目的地和箱子
			case 3:
				printf("☆");
				break;
			case 4:
				printf("★");
				break;
				//5:※		  //人
			case 5:
			case 8:
				printf("※");
				break;
			case 7:
				printf("⊙");
				break;
				//7:⊙		  //目的(3)和箱子(4)在一起
				//8:※		  //人(5)和目的(3)在一起
			}
		}
		printf("\n");
	}
}
//按键处理
void keyDown()
{
	//分析按键过程
	//定位人在哪里
	//人有两种情况:第一个是:人,第二个:人站在目的上
	int i, j;
	for (i = 0; i < 7; i++)
	{
		for (j = 0; j < 8; j++)
		{
			if (map[cas][i][j] == 5 || map[cas][i][j] == 8)
			{
				break;
			}
		}
		if (map[cas][i][j] == 5 || map[cas][i][j] == 8)
		{
			break;
		}
	}
 
	char ch = _getch();	//看不见的字符输入,+头文件 conio.h
	switch (ch)
	{
		//72 80   75 77
	case 'w':
	case 'W':
	case 72:
		//下一个地方等于空地或者是目的 能走
		if (map[cas][i - 1][j] == 0 || map[cas][i - 1][j] == 3)
		{
			//3+5=8 :表示目的和人在一起
			//新地方(map[i-1][j])人(5)来了
			map[cas][i - 1][j] += 5;
			//老地方(map[i][j])人(5)走了
			map[cas][i][j] -= 5;
		}
		//如果下一个是箱子,要进一步判断能走
		//注意点:箱子两种状态:箱子,箱子和目的在一起
		else if (map[cas][i - 1][j] == 4 || map[cas][i - 1][j] == 7)
		{
			//做箱子的下一个地方判断能不能走
			if (map[cas][i - 2][j] == 0 || map[cas][i - 2][j] == 3)
			{
				//新的地方箱子来了
				map[cas][i - 2][j] += 4;
				//箱子的位置:箱子(-4)走了 人来(+5)
				map[cas][i - 1][j] += 1;
				//原来的地方人走了
				map[cas][i][j] -= 5;
			}
 
		}
 
		break;
	case 's':
	case 'S':
	case 80:
		//下一个地方等于空地或者是目的 能走
		if (map[cas][i + 1][j] == 0 || map[cas][i + 1][j] == 3)
		{
			//3+5=8 :表示目的和人在一起
			//新地方(map[i-1][j])人(5)来了
			map[cas][i + 1][j] += 5;
			//老地方(map[i][j])人(5)走了
			map[cas][i][j] -= 5;
		}
		else if (map[cas][i + 1][j] == 4 || map[cas][i + 1][j] == 7)
		{
			//做箱子的下一个地方判断能不能走
			if (map[cas][i + 2][j] == 0 || map[cas][i + 2][j] == 3)
			{
				//新的地方箱子来了
				map[cas][i + 2][j] += 4;
				//箱子的位置:箱子(-4)走了 人来(+5)
				map[cas][i + 1][j] += 1;
				//原来的地方人走了
				map[cas][i][j] -= 5;
			}
 
		}
		break;
 
	case 'a':
	case 'A':
	case 75:
		//下一个地方等于空地或者是目的 能走
		if (map[cas][i][j - 1] == 0 || map[cas][i][j - 1] == 3)
		{
			//3+5=8 :表示目的和人在一起
			//新地方(map[i-1][j])人(5)来了
			map[cas][i][j - 1] = map[cas][i][j - 1] + 5;
			//老地方(map[i][j])人(5)走了
			map[cas][i][j] = map[cas][i][j] - 5;
			//j+=5  j=j+5
 
		}
		else if (map[cas][i][j - 1] == 4 || map[cas][i][j - 1] == 7)
		{
			//做箱子的下一个地方判断能不能走
			if (map[cas][i][j - 2] == 0 || map[cas][i][j - 2] == 3)
			{
				//新的地方箱子来了
				map[cas][i][j - 2] += 4;
				//箱子的位置:箱子(-4)走了 人来(+5)
				map[cas][i][j - 1] += 1;
				//原来的地方人走了
				map[cas][i][j] -= 5;
			}
 
		}
 
		break;
	case 'D':
	case 'd':
	case 77:
		//下一个地方等于空地或者是目的 能走
		if (map[cas][i][j + 1] == 0 || map[cas][i][j + 1] == 3)
		{
			//3+5=8 :表示目的和人在一起
			//新地方(map[i-1][j])人(5)来了
			map[cas][i][j + 1] += 5;
			//老地方(map[i][j])人(5)走了
			map[cas][i][j] -= 5;
		}
		
		//下一个地方是箱子,判断箱子的下一个地方是不是目的和空地
		else if (map[cas][i][j + 1] == 4 || map[cas][i][j + 1] == 7)
		{
			//做箱子的下一个地方判断能不能走
			if (map[cas][i][j + 2] == 0 || map[cas][i][j + 2] == 3)
			{
				//新的地方箱子来了
				map[cas][i][j + 2] += 4;
				//箱子的位置:箱子(-4)走了 人来(+5)
				map[cas][i][j + 1] += 1;
				//原来的地方人走了
				map[cas][i][j] -= 5;
			}
 
		}
		break;
	}
}
//胜负判断
//用什么判断胜负: 箱子到达目的的个数
int gameOver()
{
	int count = 0;
	//所有的地方找一遍
	for (int i = 0; i < 7; i++)
	{
		for (int j = 0; j < 8; j++)
		{
			if (map[cas][i][j] == 7)
				count++;
		}
	}
	return count;
}
//箱子数是零的时候也是胜利
int gameOver2()
{
	int count = 3;
	//所有的地方找一遍
	for (int i = 0; i < 7; i++)
	{
		for (int j = 0; j < 8; j++)
		{
			if (map[cas][i][j] == 3)
				count--;
		}
	}
	return count;
}
 
int main()
{
	while (1)
	{
		printf("\n\t用方向键或w a s d键移动※推动★进入☆\n",cas+1);
		printf("\n\t\t 共两关 第 %d 关\n",cas+1);
		drawMap();
		if (gameOver() == boxSum[cas])
		{
			cas++;
			if (cas == 2)
				break;
			else
			    printf("\n\t\t 该关 OK!按任一键进继续\n");	
		}
		keyDown();
		system("cls");
	}
	printf("游戏结束!");
	printf("\n");
	system("pause");
	return 0;
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值