跳到正文

休闲·娱乐

谁是卧底游戏

CLC114514约 9 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 9 分钟

版本

  1. v2当前
  2. v1

谁是卧底游戏

这是本蒟蒻第一次做游戏(耗费了两个月的心血)

请大佬们多多指教

C++
//谁是卧底游戏:
//陈李承于2024年10月22日编写完成
//按[F11]键开始游戏
//请各位大佬多多指教本蒟蒻。。。
#include<bits/stdc++.h>
#include<windows.h>
#define int long long
using namespace std;
vector <int> Num;
vector <int> Yes;
vector <int> No;
vector <int> Score;
vector <int> Cnt;
string Word_1[] = {{"手枪"},
				   {"萝卜"},
				   {"北京"},
				   {"牛奶"},
				   {"红军长征"},
				   {"大海"},
				   {"电脑"},
				   {"王者荣耀"},
				   {"海螺壳"},
				   {"空调"}};
string Word_2[] = {{"步枪"},
				   {"土豆"},
				   {"天津"},
				   {"豆浆"},
				   {"抗日战争"},
				   {"沙漠"},
				   {"手机"},
				   {"和平精英"},
				   {"蜗牛壳"},
				   {"电风扇"}};
//台词有限,请大佬们包容。
char next;
char start;
char costune;
char go;
char show;
char end;
bool stop;
int guess;
int correct = 0;
int error = 0;
int score = 0;
int color;
int answer;
int num;
int sum = 0;
int cnt = 0;
int pos;
signed main();
void set_color() {
	system("cls");
	cout << "                                                     设置主题" << endl;
	cout << "                                                   可爱奶咖黄【按1】" << endl;
	cout << "                                                   帅气军舰蓝【按2】" << endl;
	cout << "                                                   迷人魅力紫【按3】" << endl;
	cout << "                                                   恐怖血腥红【按4】" << endl;
	cout << "                                                     返回【按5】" << endl;
	cin >> color;
	switch(color) {
		case 1:
			system("color E7");
			set_color();
			break;
		case 2:
			system("color 9B");
			set_color();
			break;
		case 3:
			system("color 5D");
			set_color();
			break;
		case 4:
			system("color 48");
			set_color();
			break;
		case 5:
			main();
			break;
	}
}
signed main(){
	srand(time(0));
	system("cls");
	cout << "欢迎来到谁是卧底游戏V3.0版本!" << endl;
	cout << "作者:陈李承" << endl;
	Sleep(2300);
	system("cls");
	cout << "                                                     谁是卧底     ()" << endl;
	cout << "                                                  游戏记录【按1】 =|" << endl;
	cout << "                                                  开始游戏【按2】 <<" << endl;
	cout << "                                                  设置主题【按3】" << endl;
	cout << "                                                  退出游戏【按4】" << endl;
	cin >> answer;
	system("cls");
	switch(answer) {
		case 1:
			cout << "                                                     游戏记录" << endl;
			for(int i = 0; i < sum; i ++) {
				cout << "                                                  本次共玩" << Cnt[i] << "轮" << endl;
				cout << "                                                  平民胜利" << Yes[i] << "轮" << endl;
				cout << "                                                  卧底胜利" << No[i] << "轮" << endl;
				cout << "                                                  得分:" << Score[i] << "分" << endl;
				cout << endl << endl;
			}
			break;
		case 2:
			sum ++;
			system("cls");
			cout << "谁是卧底游戏! 开始!" << endl;
			Sleep(1500);
			system("cls");
			while(true) {
				cnt ++;
				num = 0;
				cout << "请输入游玩人数..." << endl;
				cin >> num;
				Num.push_back(num);
				int special = rand() % num + 1;
				system("cls");
				pos = rand() % 9;
				for(int i = 1; i <= num; i ++) {
					cout << "你是" << i << "号" << endl;
					cout << "[按任意键查看角色...]" << endl;
					cin >> costune;
					system("cls");
					if(i == special) {
						cout << Word_1[pos] << endl;
						cout << "[看完了按任意键继续...]" << endl;
						cin >> go;
						system("cls");
					}
					else {
						cout << Word_2[pos] << endl;
						cout << "[看完了按任意键继续...]" << endl;
						cin >> go;
						system("cls");
					}
				}
				cout << "到了分享身份环节啦!" << endl;
				cout << "[分享完了按任意键继续...]" << endl;
				cin >> show;
				system("cls");
				cout << "猜猜谁是卧底?" << endl;
				cin >> guess;
				system("cls");
				if(guess == special) {
					correct ++;
					cout << "猜对了!平民胜利!" << endl;
					score += 10;
				}
				else {
					error ++;
					cout << "卧底胜利!卧底是" << special <<"号" << endl;
					score -= 10;
				}
				Sleep(3000);
				system("cls");
				cout << "[下一轮游戏按1,退出游戏按0...]" << endl;
				cin >> stop;
				if(stop == false) {
					Yes.push_back(correct);
					No.push_back(error);
					Score.push_back(score);
					Cnt.push_back(cnt);
					correct = 0;
					error = 0;
					score = 0;
					cnt = 0;
					main();
				}
				else {
					system("cls");
					cout << "下一轮!" << endl;
					Sleep(1500);
					system("cls");
					continue;
				}
			break;
		}
		case 3:
			set_color();
			break;
		case 4:
			system("cls");
			cout << endl << endl;
			cout << "游戏结束!再见!" << endl << endl;
			return 0;
			break;
	}
	return 0;
}

欢迎各位大佬指点!

原文