-
个人简介
三角洲的号:难洛王
多个游戏代码
#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; }#include<windows.h> #include<conio.h> #define cl system("cls") #define wt Sleep(1000) #define swt Sleep(667) #define ssw Sleep(333) #define sr srand((rand()+1)*time(NULL)+expr+nowtime+1); #define ll long long #define INF 0x3f3f3f3f #define mx(a,b) ((a)>(b)?(a):(b)) #define mn(a,b) ((a)<(b)?(a):(b)) using namespace std; ll hp,atk,dmg,lev,mhp,matk,expr,ndexp,skexp,wpexp; ll hpx,atkx,mhpx,matkx,levx,dmgx; ll rd; ll nowtime=time(NULL); string code,str; char wd[10]={'[',']','|','\\','`','^','_','{','}','~'}; char c; string opt; vector<int> sk,csk,wp,cwp; int nowsk,nowskx,nowene,enecount=4,nowwp,nwp; bool err,fsk[20],fwp[20]; bool outloop; int sklist[50]={0,0,0,0,1,1,1,2,2,3,3,4},skcount=11; int wplist[50]={0,0,0,0,0,1,1,1,1,2,2},wpcount=10; struct skills { string name; double mul; int type; }; struct weapons { string name; double mul; int color; }; struct enemy { int boss; string say,dsay; string name; int namelg; int sklg; string skx[105]; double mulx[105]; int lhp,latk,lexp; int mode; }; struct elem { string name; int color; int mix[7]; }; skills skl[20]={{},{"拳",1,0},{"脚",1.2,0},{"劈",1.1,1},{"回血",1,2}}; weapons wpl[20]={{},{"木剑",1,7},{"铁剑",1.2,7},{"静水流涌之辉",10.13,9},{"万世流涌大典",12.18,9}}; enemy e[11]={{}, {0,"\"我是逆蝶~\"","","逆蝶",4,2,{"","创","扎"},{0,1,1.1},50,5,100,1}, {0,"\"你猜我为什么叫赌徒?\"","","赌徒",4,3,{"","拳","掌","枪"},{0,0.8,1,11.45},80,5,250,2}, {2,"\"玩恶魔轮盘赌吗?\"","\"你赢了,这是你应得的\"","赌神[BOSS]",10,6,{"","空弹","空弹","水弹","实弹","实弹","实弹"},{0,0,0,0.15,0.8,0.8,0.8},6,1,2500,2}, {1,"\"鸡蛋鸭蛋荷包蛋,我全都爱吃~\"","\"柠檬熟了...\"","刘土墨[伪BOSS]",14,1,{"","射击"},{0,-11.45},250,100,1145,1}}; elem ele[8]={{"风",11,{}},{"岩",6,{}},{"雷",5,{}},{"草",10,{}},{"水",1,{}},{"火",4,{}},{"冰",3,{}},{"物",7,{}}}; void start(); void hurt(int,int); void showhp(); void fight(int,ll); void rdup(); string getcode(); void incode(string); char apb(int); int getc(char); int bwd(char); ll pw(int,int); void swapsk(); void getsk(); void changewp(); void getwp(); void setpos(int,int); void setcolor(int); bool havesk(int); bool havewp(int); int main() { start(); nowtime=time(NULL); while(true) { cl; if(nowtime!=time(NULL)) { expr+=(time(NULL)-nowtime)*ndexp/100; cout<<"在线经验增加 "<<(time(NULL)-nowtime)*ndexp/100<<" 点"<<endl; nowtime=time(NULL); swt; cl; } cout<<"请选择接下来的操作:1)升级 2)技能 3)武器 4)打怪 5)获取存档码 6)输入存档码"<<endl; while(true) { if(kbhit()) { c=_getch(); if(c=='1') { cout<<"加载中"<<endl; ssw; cl; rdup(); break; } if(c=='2') { cout<<"加载中"<<endl; ssw; outloop=false; while(true) { cl; skexp=(sk.size()-1)*300; cout<<"当前技能:"<<endl; for(int i=1;i<sk.size();i++) { cout<<i<<":"<<skl[sk[i]].name<<endl; } cout<<"升级所需经验: "<<skexp<<endl; cout<<"当前经验: "<<expr<<endl; swt; cout<<"请选择接下来的操作 1)切换技能位置 2)抽取技能 3)离开"<<endl; while(true) { if(kbhit()) { c=_getch(); if(c=='1') { cout<<"请输入切换技能的编号"<<endl; swapsk(); break; } if(c=='2') { if(expr>=skexp) { expr-=skexp; getsk(); } else { cout<<"经验不足"<<endl; wt; cl; } break; } if(c=='3') { cl; outloop=true; break; } } } if(outloop) { break; } } break; } if(c=='3') { cout<<"加载中"<<endl; ssw; outloop=false; while(true) { cl; wpexp=(wp.size()-1)*300; cout<<"当前武器:"<<endl; setcolor(wpl[wp[nowwp]].color); cout<<wpl[wp[nowwp]].name<<endl; setcolor(7); cout<<"已有武器:"<<endl; for(int i=1;i<wp.size();i++) { cout<<i<<":"; setcolor(wpl[wp[i]].color); cout<<wpl[wp[i]].name<<endl; setcolor(7); } cout<<"抽武器所需经验:"<<wpexp<<endl; cout<<"当前经验:"<<expr<<endl; swt; cout<<"请输入接下来的操作 1)切换武器 2)抽取武器 3)离开"<<endl; while(true) { if(kbhit()) { c=_getch(); if(c=='1') { cout<<"请输入切换武器的编号"<<endl; changewp(); break; } if(c=='2') { if(expr>=wpexp) { expr-=wpexp; getwp(); } else { cout<<"经验不足"<<endl; wt; cl; } break; } if(c=='3') { cl; outloop=true; break; } } } if(outloop) { break; } } break; } if(c=='4') { outloop=false; cout<<"加载中"<<endl; ssw; cl; cout<<"请输入要挑战的敌人 "; for(int i=1;i<=enecount;i++) { cout<<i<<")"<<e[i].name<<" "; } cout<<enecount+1<<")退出"; cout<<endl; while(true) { if(kbhit()) { c=_getch(); if(c==enecount+1+48) { outloop=true; break; } for(int i=1;i<=enecount;i++) { if(c==i+48) { if(e[i].boss==0) { cout<<"请输入敌人等级:"<<endl; cin>>levx; if(1<=levx&&levx<=1e10) { fight(i,levx); } else { cout<<"无效操作"<<endl; } outloop=true; break; } if(e[i].boss==1||e[i].boss==2) { fight(i,1); outloop=true; break; } } } } if(outloop) { break; } } if(outloop) { break; } } if(c=='5') { cout<<"加载中"<<endl; ssw; cl; cout<<"以下是存档码: "<<endl; cout<<getcode()<<endl; return 0; } if(c=='6') { cout<<"加载中"<<endl; ssw; cl; cout<<"请输入存档码: "<<endl; cin>>str; incode(str); if(err==true) { cout<<"存档码错误"<<endl; wt; } else { if(nowwp!=0) { nowwp=nwp; } sk.clear(); sk.push_back(0); for(int i=0;i<csk.size();i++) { sk.push_back(csk[i]); } wp.clear(); wp.push_back(3); for(int i=0;i<cwp.size();i++) { wp.push_back(cwp[i]); } } cl; break; } } } } return 0; } void start() { lev=1; ndexp=lev*300; skexp=300; wpexp=300; expr=0; mhp=128; matk=16; sk.push_back(0); sk.push_back(1); wp.push_back(3); wp.push_back(1); nowwp=1; } void hurt(ll d,int t,int s) { if(t==1) { cout<<"你"; if(skl[sk[s]].type==1) { cout<<"拿起"; setcolor(wpl[wp[nowwp]].color); cout<<"["<<wpl[wp[nowwp]].name<<"]"; setcolor(7); cout<<","; } cout<<"使用了"; if(wp[nowwp]==3) { if(skl[sk[s]].type==1) { setcolor(9); cout<<"[独舞之邀]"; setcolor(7); } else { if(skl[sk[s]].type==2) { setcolor(9); cout<<"[孤心沙龙]"; setcolor(7); } else { cout<<"["<<skl[sk[s]].name<<"]"; } } } else { cout<<"["<<skl[sk[s]].name<<"]"; } if(skl[sk[nowsk]].type==2&&e[nowene].boss!=2) { cout<<"回复了 "<<d<<" 点血量"<<endl; } else { if(e[nowene].boss==2&&skl[sk[s]].name!="拳") { cout<<endl; cout<<"但被 "<<e[nowene].name<<" 强制更改为了[拳],"<<endl; } cout<<"对 "<<e[nowene].name<<" 造成了 "<<d<<" 点伤害"<<endl; } } else { cout<<e[nowene].name<<" 使用了["<<e[nowene].skx[nowskx]<<"],"; cout<<"对你造成了 "<<d<<" 点伤害"<<endl; } } void showhp() { hp=mn(hp,mhp); hpx=mn(hpx,mhpx); int sh=mx(0,mx(int(sh>0),hp*40/mhp)); int shx=mx(0,mx(int(shx>0),hpx*40/mhpx)); setcolor(7); cout<<"你的血量:"; for(int i=1;i<=e[nowene].namelg;i++) { cout<<" "; } cout<<"("; setcolor(4); for(int i=1;i<=sh/2;i++) { cout<<"#"; } if(sh%2==1) { cout<<"_"; } for(int i=1;i<=20-sh/2-(sh%2==1);i++) { cout<<" "; } setcolor(7); cout<<")"; cout<<endl; cout<<e[nowene].name<<" 的血量: ("; setcolor(4); for(int i=1;i<=shx/2;i++) { cout<<"#"; } if(shx%2==1) { cout<<"_"; } for(int i=1;i<=20-shx/2-(shx%2==1);i++) { cout<<" "; } setcolor(7); cout<<")"; cout<<endl; } void fight(int ene,ll elev) { cl; nowene=ene; nowsk=1; nowskx=1; hp=mhp; atk=matk; cout<<e[ene].say<<endl; swt; if(e[ene].boss==0||e[ene].boss==1) { mhpx=e[ene].lhp*elev,matkx=e[ene].latk*elev; hpx=mhpx,atkx=matkx; } if(e[ene].boss==2) { mhpx=(e[ene].lhp+0.5)*matk,matkx=e[ene].latk*mhp; hpx=mhpx,atkx=matkx; } while(hpx>0&&hp>0) { if(e[ene].boss==2) { dmg=atk; } else { if(skl[sk[nowsk]].type==0) { dmg=skl[sk[nowsk]].mul*atk; } if(skl[sk[nowsk]].type==1) { dmg=(skl[sk[nowsk]].mul*wpl[wp[nowwp]].mul)*atk; } if(skl[sk[nowsk]].type==2) { if(wp[nowwp]==3) { dmg=10.13*atk; } else { dmg=skl[sk[nowsk]].mul*atk; } } } dmgx=e[ene].mulx[nowskx]*matkx; if(skl[sk[nowsk]].type==2&&e[ene].boss!=2) { hp+=dmg; } else { hpx-=dmg; } hurt(dmg,1,nowsk); showhp(); if(hpx<=0) { swt; break; } if(e[ene].boss==0) { swt; } if(e[ene].boss==1||e[ene].boss==2) { wt; } hp-=dmgx; hurt(dmgx,0,0); showhp(); if(e[ene].boss==0) { swt; } if(e[ene].boss==1||e[ene].boss==2) { wt; } nowsk=nowsk%(sk.size()-1)+1; if(e[ene].mode==1) { nowskx=nowskx%(e[ene].sklg)+1; } if(e[ene].mode==2) { sr; nowskx=rand()%e[ene].sklg+1; } } if(hp>0) { if(e[ene].dsay!="") { cout<<e[ene].dsay<<endl; wt; } cout<<"你胜利了"<<endl; if(e[ene].boss==0) { expr+=levx*e[ene].lexp; cout<<"你获得了 "<<levx*e[ene].lexp<<" 点经验"<<endl; } if(e[ene].boss==1) { expr+=e[ene].lexp; cout<<"你获得了 "<<e[ene].lexp<<" 点经验"<<endl; } if(e[ene].boss==2) { expr+=lev*e[ene].lexp; cout<<"你获得了 "<<lev*e[ene].lexp<<" 点经验"<<endl; } } else { cout<<"你失败了"<<endl; } wt; cl; } void up() { if(expr>=ndexp) { expr-=ndexp; lev+=1; ndexp=lev*(200+5*sqrt(lev)); mhp+=64+int(sqrt(mhp)); matk+=8+int(sqrt(matk)); } else { cout<<"经验不足"<<endl; wt; } } void rdup() { ru: cout<<"等级: "<<lev<<endl; cout<<"血量: "<<mhp<<endl; cout<<"攻击: "<<matk<<endl; cout<<"经验: "<<expr<<endl; cout<<"升级所需经验: "<<ndexp<<endl; swt; cout<<"是否升级? 1)升级 2)离开"<<endl; while(true) { if(kbhit()) { c=_getch(); if(c=='1') { up(); cl; goto ru; break; } if(c=='2') { cl; return; } } } } string getcode() { code=""; sr; rd=rand(); ll lx=lev+114514+rd*13; ll hx=mhp+1919+rd*11; ll ax=matk+810+rd*9; ll ex=expr+182376+rd*7; ll nx=ndexp+1013+rd*5; ll skex=skexp+114+rd*18; ll nwpx=max(1,nowwp)+376+rd*rd; ll skx=0; ll wpx=0; for(int i=1;i<sk.size();i++) { skx*=11; skx+=11*sk[i]; } skx+=514+rd*10; for(int i=1;i<wp.size();i++) { wpx*=11; wpx+=11*wp[i]; } wpx+=182+rd*14; while(lx!=0) { code+=apb(lx%84); lx/=84; } sr; code+=wd[rand()%10]; while(hx!=0) { code+=apb(hx%84); hx/=84; } sr; code+=wd[rand()%10]; while(ax!=0) { code+=apb(ax%84); ax/=84; } sr; code+=wd[rand()%10]; while(ex!=0) { code+=apb(ex%84); ex/=84; } sr; code+=wd[rand()%10]; while(nx!=0) { code+=apb(nx%84); nx/=84; } sr; code+=wd[rand()%10]; while(skex!=0) { code+=apb(skex%84); skex/=84; } sr; code+=wd[rand()%10]; while(skx!=0) { code+=apb(skx%84); skx/=84; } sr; code+=wd[rand()%10]; while(wpx!=0) { code+=apb(wpx%84); wpx/=84; } sr; code+=wd[rand()%10]; while(nwpx!=0) { code+=apb(nwpx%84); nwpx/=84; } sr; code+=wd[rand()%10]; while(rd!=0) { code+=apb(rd%84); rd/=84; } return code; } char apb(int x) { if(x<=25) { return char(x+65); } else { if(26<=x&&x<=51) { return char(x+71); } else { return char(x-19); } } } int getc(char x) { int y=int(x); if(bwd(x)!=-1) { return -1; } if(65<=y&&y<=90) { return y-65; } else { if(97<=y&&y<=122) { return y-71; } else { if(33<=y&&y<=64) { return y+19; } else { err=true; } } } } void incode(string x) { csk.clear(); cwp.clear(); memset(fsk,0,sizeof(fsk)); memset(fwp,0,sizeof(fwp)); err=false; string s[20]; int y=0,z=0; ll lx=0,hx=0,ax=0,ex=0,nx=0,skx=0,skex=0,wpx=0,nwpx=0; for(int i=0;i<x.size();i++) { if(bwd(x[i])!=-1) { y++; } else { s[y]+=x[i]; } } if(y!=9) { if(y==10||s[10]=="1013") { nowwp=0; } else { err=true; return; } } for(int i=0;i<s[9].size();i++) { z+=getc(s[9][i])*pw(84,i); } for(int i=0;i<s[0].size();i++) { lx+=getc(s[0][i])*pw(84,i); } lx-=z*13+114514; for(int i=0;i<s[1].size();i++) { hx+=getc(s[1][i])*pw(84,i); } hx-=z*11+1919; for(int i=0;i<s[2].size();i++) { ax+=getc(s[2][i])*pw(84,i); } ax-=z*9+810; for(int i=0;i<s[3].size();i++) { ex+=getc(s[3][i])*pw(84,i); } ex-=z*7+182376; for(int i=0;i<s[4].size();i++) { nx+=getc(s[4][i])*pw(84,i); } nx-=z*5+1013; for(int i=0;i<s[5].size();i++) { skex+=getc(s[5][i])*pw(84,i); } skex-=z*18+114; for(int i=0;i<s[6].size();i++) { skx+=getc(s[6][i])*pw(84,i); } skx-=z*10+514; for(int i=0;i<s[7].size();i++) { wpx+=getc(s[7][i])*pw(84,i); } wpx-=z*14+182; for(int i=0;i<s[8].size();i++) { nwpx+=getc(s[8][i])*pw(84,i); } nwpx-=z*z+376; nwp=nwpx; int t=0; ll skxx=skx; while(skxx!=0) { skxx/=11; csk.push_back(0); } csk.pop_back(); while(skx!=0) { if(fsk[skx%11]==true) { err=true; return; } fsk[skx%11]=true; csk[csk.size()-t]=skx%11; skx/=11; t++; } t=0; ll wpxx=wpx; while(wpxx!=0) { wpxx/=11; cwp.push_back(0); } cwp.pop_back(); while(wpx!=0) { if(fwp[wpx%11]==true) { err=true; return; } fwp[wpx%11]=true; cwp[cwp.size()-t]=wpx%11; wpx/=11; t++; } if(lx<=0||hx<=0||ax<=0||ex<0||nx<=0||skex<=0||nwp<0||nwp>cwp.size()) { err=true; return; } else { lev=lx,mhp=hx,matk=ax,expr=ex,ndexp=nx,skexp=skex; } } int bwd(char x) { for(int i=0;i<=9;i++) { if(x==wd[i]) { return i; } } return -1; } ll pw(int x,int y) { ll z=1; for(int i=1;i<=y;i++) { z*=x; } return z; } void swapsk() { int x=0,y=0; cout<<"请输入第一个技能:"<<endl; cin>>x; cout<<"请输入第二个技能:"<<endl; cin>>y; if(x>=1&&x<sk.size()&&y>=1&&y<sk.size()&&x!=y) { swap(sk[x],sk[y]); cout<<"切换技能成功"<<endl; swt; cl; return; } if(x>=1&&x<sk.size()&&y>=1&&y<sk.size()&&x==y) { cout<<"和自己换?无不无聊啊 (-_-')"<<endl; wt; cl; return; } cout<<"技能切换失败"<<endl; wt; cl; } void getsk() { sr; int t=rand()%skcount+1; if(havesk(sklist[t])==false&&sklist[t]!=0) { cout<<"抽取成功,抽中了技能["<<skl[sklist[t]].name<<"]"<<endl; sk.push_back(sklist[t]); wt; cl; } else { cout<<"抽取失败"<<endl; wt; cl; } } void changewp() { int x=0; cin>>x; if(x>=1&&x<wp.size()) { nowwp=x; return; } cout<<"切换武器失败"<<endl; wt; cl; } void getwp() { sr; int t=rand()%wpcount+1; if(havewp(wplist[t])==false&&wplist[t]!=0) { cout<<"抽取成功,抽中了武器"; setcolor(wpl[wplist[t]].color); cout<<"["<<wpl[wplist[t]].name<<"]"<<endl; setcolor(7); wp.push_back(wplist[t]); wt; cl; } else { cout<<"抽取失败"<<endl; wt; cl; } } void setpos(int x,int y) { COORD posx; posx.X=x; posx.Y=y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),posx); } void setcolor(int x) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x); } bool havesk(int x) { for(int i=1;i<sk.size();i++) { if(sk[i]==x) { return true; } } return false; } bool havewp(int x) { for(int i=1;i<wp.size();i++) { if(wp[i]==x) { return true; } } return false; } /* 更新日志: v0.1.0: 基础功能 v0.1.1: 由于某些人的Dev-C++比较旧, 就把auto去掉了 */ //iIV}wlK~RKG~q@=tv|z@K|e7G{YjK^%+H^Ye"L{Wf -
通过的题目
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 65
- 66
- 67
- 68
- 69
- 70
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 91
- 92
- 93
- 94
- 95
- 96
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 130
- 132
- 133
- 135
- 137
- 138
- 140
- 141
- 142
- 143
- 144
- 148
- 149
- 150
- 152
- 154
- 156
- 158
- 162
- 163
- 164
- 168
- 169
- 172
- 173
- 176
- 177
- 182
- 183
- 186
- 189
- 190
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 200
- 205
- 208
- 216
- 217
- 222
- 229
- 230
- 232
- 234
- 241
- 245
- 246
- 250
- 260
- 265
- 266
- 277
- 280
- 282
- 286
- 297
- 351
- 353
- 354
- 356
- 357
- 358
- 360
- 361
- 362
- 371
- 378
- 386
- 389
- 407
- 410
- 412
- 414
- 420
- 431
- 442
- 454
- 465
- 466
- 468
- 469
- 470
- 472
- 474
- 475
- 482
- 483
- 484
- 485
- 486
- 492
- 518
- 535
- 545
- 553
- 554
- 561
- 562
- 567
- 569
- 573
- 575
- 577
- 584
- 586
- 589
- 602
- 613
- 638
- 641
- 645
- 647
- 648
- 649
- 651
- 653
- 656
- 657
- 659
- 661
- 664
- 665
- 666
- 668
- 670
- 672
- 673
- 674
- 675
- 677
- 680
- 684
- 685
- 687
- 690
- 691
- 693
- 694
- 696
- 697
- 699
- 701
- 702
- 704
- 708
- 709
- 711
- 712
- 713
- 714
- 715
- 716
- 717
- 718
- 720
- 722
- 724
- 726
- 728
- 729
- 732
- 735
- 738
- 744
- 748
- 749
- 751
- 752
- 754
- 755
- 758
- 761
- 762
- 763
- 764
- 765
- 768
- 773
- 775
- 779
- 781
- 785
- 786
- 787
- 788
- 789
- 790
- 796
- 800
- 809
- 810
- 811
- 812
- 813
- 814
- 815
- 816
- 817
- 818
- 819
- 820
- 821
- 822
- 823
- 824
- 825
- 826
- 827
- 828
- 829
- 830
- 831
- 832
- 833
- 834
- 835
- 836
- 837
- 838
- 839
- 840
- 841
- 842
- 843
- 844
- 845
- 846
- 847
- 848
- 849
- 850
- 851
- 852
- 853
- 854
- 855
- 856
- 857
- 859
- 860
- 861
- 862
- 863
- 864
- 865
- 866
- 867
- 868
- 869
- 870
- 871
- 872
- 873
- 874
- 875
- 876
- 877
- 878
- 879
- 880
- 881
- 882
- 883
- 884
- 885
- 886
- 887
- 888
- 889
- 890
- 891
- 892
- 893
- 894
- 895
- 896
- 898
- 899
- 900
- 901
- 902
- 903
- 904
- 905
- 906
- 907
- 908
- 909
- 910
- 912
- 913
- 914
- 915
- 916
- 917
- 918
- 919
- 920
- 921
- 922
- 923
- 924
- 925
- 926
- 927
- 928
- 929
- 930
- 931
- 932
- 933
- 934
- 935
- 936
- 937
- 938
- 939
- 940
- 941
- 942
- 943
- 944
- 945
- 946
- 947
- 948
- 949
- 950
- 951
- 952
- 953
- 954
- 955
- 956
- 957
- 958
- 959
- 960
- 961
- 962
- 963
- 964
- 965
- 966
- 967
- 968
- 969
- 970
- 971
- 972
- 973
- 974
- 975
- 976
- 977
- 978
- 979
- 980
- 981
- 982
- 983
- 984
- 985
- 986
- 987
- 988
- 989
- 990
- 991
- 993
- 994
- 995
- 996
- 997
- 998
- 999
- 1000
- 1001
- 1002
- 1003
- 1004
- 1005
- 1006
- 1007
- 1008
- 1009
- 1011
- 1012
- 1013
- 1014
- 1015
- 1016
- 1017
- 1018
- 1019
- 1020
- 1021
- 1023
- 1024
- 1025
- 1026
- 1027
- 1028
- 1029
- 1030
- 1031
- 1032
- 1034
- 1035
- 1036
- 1037
- 1038
- 1039
- 1040
- 1041
- 1042
- 1043
- 1044
- 1045
- 1046
- 1047
- 1048
- 1049
- 1050
- 1052
- 1055
- 1057
- 1058
- 1059
- 1062
- 1063
- 1064
- 1067
- 1068
- 1069
- 1070
- 1071
- 1073
- 1075
- 1077
- 1078
- 1079
- 1080
- 1081
- 1083
- 1084
- 1085
- 1086
- 1088
- 1089
- 1090
- 1091
- 1092
- 1093
- 1094
- 1095
- 1097
- 1098
- 1099
- 1102
- 1104
- 1105
- 1107
- 1108
- 1110
- 1112
- 1114
- 1115
- 1117
- 1118
- 1119
- 1120
- 1121
- 1122
- 1123
- 1126
- 1127
- 1128
- 1130
- 1131
- 1132
- 1133
- 1134
- 1135
- 1138
- 1140
- 1142
- 1143
- 1145
- 1149
- 1153
- 1154
- 1155
- 1156
- 1157
- 1160
- 1162
- 1163
- 1166
- 1175
- 1177
- 1178
- 1180
- 1182
- 1183
- 1184
- 1185
- 1186
- 1187
- 1188
- 1189
- 1190
- 1191
- 1192
- 1193
- 1194
- 1195
- 1196
- 1197
- 1198
- 1200
- 1201
- 1202
- 1203
- 1204
- 1206
- 1209
- 1211
- 1212
- 1213
- 1214
- 1215
- 1216
- 1218
- 1219
- 1220
- 1221
- 1222
- 1223
- 1224
- 1225
- 1226
- 1227
- 1230
- 1231
- 1232
- 1233
- 1234
- 1235
- 1236
- 1237
- 1238
- 1239
- 1241
- 1242
- 1243
- 1244
- 1245
- 1247
- 1250
- 1252
- 1259
- 1261
- 1263
- 1265
- 1266
- 1274
- 1276
- 1277
- 1278
- 1279
- 1280
- 1281
- 1282
- 1283
- 1284
- 1285
- 1291
- 1294
- 1295
- 1296
- 1298
- 1300
- 1301
- 1302
- 1303
- 1304
- 1305
- 1309
- 1312
- 1313
- 1314
- 1316
- 1317
- 1319
- 1320
- 1321
- 1322
- 1325
- 1326
- 1328
- 1329
- 1341
- 1342
- 1343
- 1344
- 1345
- 1347
- 1348
- 1349
- 1351
- 1352
- 1353
- 1354
- 1355
- 1357
- 1358
- 1359
- 1360
- 1361
- 1362
- 1363
- 1364
- 1365
- 1366
- 1367
- 1368
- 1371
- 1373
- 1376
- 1378
- 1381
- 1382
- 1383
- 1384
- 1386
- 1388
- 1389
- 1392
- 1393
- 1394
- 1395
- 1396
- 1397
- 1398
- 1399
- 1400
- 1401
- 1402
- 1403
- 1404
- 1405
- 1407
- 1408
- 1410
- 1412
- 1413
- 1418
- 1419
- 1420
- 1422
- 1425
- 1426
- 1427
- 1429
- 1430
- 1433
- 1434
- 1436
- 1443
- 1475
- 1477
- 1483
- 1484
- 1485
- 1488
- 1489
- 1491
- 1492
- 1493
- 1494
- 1495
- 1498
- 1499
- 1500
- 1501
- 1502
- 1505
- 1506
- 1507
- 1508
- 1509
- 1511
- 1512
- 1517
- 1538
- 1547
- 1551
- 1554
- 1564
- 1576
- 1584
- 1585
- 1594
- 1595
- 1622
- 1637
- 1639
- 1661
- 1666
- 1670
- 1673
- 1675
- 1676
- 1677
- 1678
- 1684
- 1685
- 1686
- 1687
- 1688
- 1700
- 1701
- 1722
- 1725
- 1732
- 1742
- 1763
- 1764
- 1782
- 1783
- 1818
- 1828
- 1848
- 1873
- 1885
- 1888
- 1954
- 1966
- 1980
- 2000
- 2078
- 2117
- 2126
- 2230
- 2249
- 2307
- 2308
- 2309
- 2310
- 2311
- 2313
- 2314
- 2315
- 2316
- 2317
- 2318
- 2319
- 2332
- 2419
- 2422
- 2433
- 2445
- 2451
- 2466
- 2491
- 2495
- 2496
- 2503
- 2511
- 2513
- 2539
- 2549
- 2550
- 2554
- 2555
- 2583
- 2590
- 2596
- 2617
- 2627
- 2630
- 2635
- 2800
- 2939
- 2953
- 2956
- 3004
- 3035
- 3047
- 3064
- 3089
- 3094
- 3098
- 3099
- 3102
- 3103
- 3104
- 3105
- 3106
- 3111
- P0165
- P0151
- P0131
- P0168
- P0147
- 3179
- 3216
- 3240
- 3244
- 3245
- 3246
- 3272
- 3273
- 3274
- 3275
- 3276
- 3277
- 3278
- 3280
- 3281
- 3291
- 3299
- 3300
- 3301
- 3302
- 3311
- 3312
- 3314
- 3332
- 3333
- 3336
- 3345
- 3346
- 3347
- 3348
- 3349
- 3409
- 3410
- 3412
- 3425
- 3436
- 3437
- 3450
- 3453
- 3456
- 3457
- 3467
- 3482
- 3483
- 3484
- 3485
- 3486
- 3487
- 3488
- 3489
- 3490
- 3491
- 3492
- 3494
- 3500
- 3503
- 3512
- 3514
- 3534
- 3536
- 3551
- 3554
- 3556
- 3569
- 3576
- 3583
- 3600
- 3601
- 3602
- 3666
- 3667
- 3668
- 3670
- 3671
- 3672
- 3673
-
最近活动
- 小云雀杯提高组重现 IOI
- 小云雀杯普及组重现 IOI
- 2026年GESP五级模拟题 IOI
- 2026年GESP四级模拟题 IOI
- 高级C2班期末小测【曹浩冉】 ACM/ICPC
- 少年宫周日晚上初级c1班【2026/6/7张正标】 作业
- 少年宫周三晚上高级c2班【曹浩冉】第十一周 作业
- 少年宫周三晚上高级c2班【曹浩冉】第九周 作业
- 红盾周六晚上班【动态规划-LIS/LCS】(zzb) 作业
- 少年宫周三晚上高级c2班【曹浩冉】第八周 作业
- 红盾周六晚上班【动态规划】(zzb) 作业
- 少年宫周三下午中级b3班【曹浩冉】第七周 作业
- 红盾周六晚上班【栈和队列】(zzb) 作业
- 少年宫周三晚上高级c2班【曹浩冉】第六周 作业
- 红盾周六晚上班【深搜】(zzb) 作业
- 红盾周六晚上班【递归函数】(zzb) 作业
- 高级c2班第四周随堂测试 IOI
- 少年宫周三晚上高级c2班【曹浩冉】第五周 作业
- 少年宫周三下午中级b3班【曹浩冉】第五周 作业
- 红盾周六晚上班【综合练习】(zzb) 作业
- 红盾周六晚上班【二分&二分查找】(zzb) 作业
- 红盾周六晚上班开学测 IOI
- 红盾周六晚上班(模拟和枚举zzb) 作业
- 红盾周六晚上班(位运算zzb) 作业
- 红盾周六晚上班(贪心算法zzb) 作业
- 红盾周六晚上班(差分前缀和zzb) 作业
- 红盾周六晚上班(数据排序&结构体) 作业
- GESP八级编程题目 作业
- GESP三级编程题目 作业
- GESP二级编程题目 作业
- GESP一级编程题目 作业
- 红盾算法班(综合练习) 作业
- 红盾周六晚上班(函数) 作业
- 少年宫周五晚上中级A2班【吴飞】(位运算2) 作业
- 少年宫周日晚上初级A2班【ZZB】(二维数组) 作业
- 少年宫周日晚上初级A1班【ZZB】(循环、一维数组综合练习) 作业
- 红盾周六晚上班(高精度算法) 作业
- 少年宫周日晚上初级A1班【ZZB】(一维数组2) 作业
- 红盾周六晚上班(字符数组) 作业
- 红盾周六晚上班(二维数组2) 作业
- 少年宫周日晚上初级A2班【ZZB】(循环嵌套2) 作业
- 红盾周六晚上班(二维数组) 作业
- GESP202509一级题目 IOI
- 少年宫周日晚上初级A2班 IOI
- 红盾周六晚上班(一维数组2) 作业
- 少年宫周日晚上初级A2班【ZZB】(循环嵌套) 作业
- 少年宫周日晚上初级A2班【ZZB】(while循环) 作业
- 少年宫周日晚上初级A2班【ZZB】(for循环) 作业
-
最近编写的题解
题目标签
- 语言基础
- 201
- 竞赛
- 118
- 循环语句
- 117
- 动态规划
- 101
- NOIP
- 84
- 字符串
- 84
- 其他
- 81
- 年份
- 68
- 搜索
- 66
- 字符数组
- 58
- 数据结构
- 56
- 一维数组
- 49
- 贪心
- 47
- 选择语句
- 44
- 二维数组
- 44
- 普及组
- 42
- python
- 41
- 语言入门
- 39
- 一本通
- 37
- 递归
- 36