正文
增加 9 行删除 358 行
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364```cpp// Copyright (C) since 2026 _auto_ / hwz007// All rights reserved// 编译系统要求 G++17 及以上,Windows 系统// ( 游戏里有豪玩的彩蛋 )#include<bits/stdc++.h>#define endl '\n'#include<windows.h>using namespace std;typedef long long ll;typedef pair<int, int> pii;struct _OIer{string name, happy;int good;};vector<_OIer> OIer;int MONEY;void mycls(string s = ""){system("cls");}void NoworkVoid(string s){return;}int NoworkInt(string s){return 0;}bool checkJ(string s, string t, void work(string s)){cout << s << endl;string c; cin >> c;work(c);return t == "ALL" || c == t;}int checkJ(string s, string t, int work(string s)){cout << s << endl;string c; cin >> c;return work(c);}void printH(string s, int del){for(auto x : s){cout << x;Sleep(del);}}void GameOver(string rea){cout << endl;if(rea == "student"){printH("你没有了学员\n\n游戏结束 !!", 100);cout << endl;}if(rea == "money"){printH("你破产了\n\n游戏结束 !!", 100);cout << endl;}if(rea == "colourEgg"){printH("[彩蛋]\n\n因为你的刷钱行为,遭到了神秘喵的制裁,你失败了喵~\n\n游戏结束喵~", 100);cout << endl;}exit(0);}void AFO(string name){cout << name << " 因为压力过大而退役" << endl << endl;vector<_OIer> newOIer;for(auto [x, y, z] : OIer){if(x != name) newOIer.push_back({x, y, z});}OIer = newOIer;if(OIer.empty()){GameOver("student");}}string nxtHappy(string x, string name){if(x == "低") return "中";if(x == "中") return "高";if(x == "高") return "极高";if(x == "极高") return "爆表";return "";}string nxtLowHappy(string x){if(x == "低") return "低";if(x == "中") return "低";if(x == "高") return "中";if(x == "极高") return "高";return "";}string changeHappy(string x, int y, string name){while(y > 100){x = changeHappy(x, 100, name);y -= 100;}int rnd = rand() % 100 + 1;if(rnd <= y){x = nxtHappy(x, name);}return x;}string changeLowHappy(string x, int y){while(y > 100){changeLowHappy(x, 100);y -= 100;}int rnd = rand() % 100 + 1;if(rnd <= y){x = nxtLowHappy(x);}return x;}int changeGood(int x, int y){int rnd = rand() % 3 + 1;return x + y * rnd;}void checkHappy(){while(true){bool flag = false;for(auto [x, y, z] : OIer){if(y == "爆表"){flag = true, AFO(x);Sleep(300);break;}}if(!flag) break;}}void checkMoney(){if(MONEY < 0){GameOver("money");}}void checkOver(){checkMoney();checkHappy();}int checkPro(string s){if(s == "1") return 1;if(s == "2") return 2;if(s == "3") return 3;if(s == "4") return 4;if(s == "5") return 5;if(s == "6") return 6;if(s == "7") return 7;return 0;}int calcProN(int x){if(x == 1) return 10;if(x == 2) return 30;if(x == 3) return 50;if(x == 4) return 70;if(x == 5) return 90;if(x == 6) return 110;if(x == 7) return 130;return 0;}int calcProG(int x){if(x == 1) return 5;if(x == 2) return 10;if(x == 3) return 15;if(x == 4) return 20;if(x == 5) return 25;if(x == 6) return 30;if(x == 7) return 35;return 0;}void Xun(){mycls();int cho = checkJ("请选择题目难度 : \n1.入门 2.普及- 3.普及/提高- 4.普及+/提高 5.提高+/省选- 6.省选/NOI- 7.NOI/NOI+/CTSC", "ALL", checkPro);int ProN = calcProN(cho), ProG = calcProG(cho);mycls();for(int i = 1; i <= 6; i++){cout << "训练中";for(int j = 1; j <= i % 3 + 1; j++){cout << ".";}cout << endl;Sleep(300);mycls();}cout << "训练完成 !" << endl << endl;cout << "训练结果 :" << endl << endl;cout << "经费 : " << MONEY << " -> " << (MONEY -= 1000) << endl << endl;Sleep(500);for(int i = 0; i < OIer.size(); i++){auto [x, y, z] = OIer[i];cout << x << " 压力 : " << OIer[i].happy << " -> " << (OIer[i].happy = changeHappy(y, ProN, x)) << " 能力 : " << OIer[i].good << " -> " << (OIer[i].good = changeGood(z, ProG)) << endl << endl;Sleep(200);}checkOver();checkJ("( 输入任意字符以确认 )", "ALL", mycls);}void Ji(){mycls();int newMoney = MONEY;vector<_OIer> bx;for(auto [x, y, z] : OIer){cout << "请选择参加集训的人员 : " << endl << endl;cout << "你希望 " << x << " 参加集训吗 ( 希望请输入 'Y' [区分大小写]) 预计剩余经费 : " << MONEY << " -> " << newMoney - 10000 << endl;if(checkJ("", "Y", NoworkVoid)){newMoney -= 10000;bx.push_back({x, y, z});}}mycls();for(int i = 1; i <= 6; i++){cout << "集训中";for(int j = 1; j <= i % 3 + 1; j++){cout << ".";}cout << endl;Sleep(300);mycls();}cout << "集训完成 !" << endl << endl;cout << "集训结果 :" << endl << endl;cout << "经费 : " << MONEY << " -> " << (MONEY = newMoney) << endl << endl;Sleep(500);for(auto [x, y, z] : bx){for(int i = 0; i < OIer.size(); i++){if(OIer[i].name != x) continue;if(OIer[i].happy != "极高"){cout << x << " 压力 : " << y << " -> " << (OIer[i].happy = "极高") << " 能力 : " << z << " -> " << (OIer[i].good = changeGood(z, 50)) << endl << endl;}else{cout << x << " 压力 : " << y << " -> " << (OIer[i].happy = "爆表") << " 能力 : " << z << " -> " << (OIer[i].good = changeGood(z, 50)) << endl << endl;}Sleep(200);break;}}checkOver();checkJ("( 输入任意字符以确认 )", "ALL", mycls);}void Bi(){mycls();//---------------GameOver("colourEgg");//---------------cout << "功能仍在开发中哟~" << endl << endl;checkJ("( 输入任意字符以确认 )", "ALL", mycls);}void Yu(){mycls();for(int i = 1; i <= 6; i++){cout << "娱乐中";for(int j = 1; j <= i % 3 + 1; j++){cout << ".";}cout << endl;Sleep(300);mycls();}cout << "娱乐完成 !" << endl << endl;cout << "娱乐结果 :" << endl;for(int i = 0; i < OIer.size(); i++){auto [x, y, z] = OIer[i];cout << x << " 压力 : " << OIer[i].happy << " -> " << (OIer[i].happy = changeLowHappy(y, 120)) << endl << endl;Sleep(200);}checkJ("( 输入任意字符以确认 )", "ALL", mycls);}void checkit(string s){if(s == "1") Xun();else if(s == "2") Ji();else if(s == "3") Bi();else if(s == "4") Yu();else{mycls();GameOver("colourEgg");}}void PrintTime(int week){cout << "第 " << week << " 周" << endl << endl;}void PrintMoney(){cout << " 经费 : " << MONEY << " $" << endl << endl;}void PrintOIer(){for(auto [x, y, z] : OIer){cout << x << " 压力 : " << y << " 能力 : " << z << endl << endl;}}void InitMoney(){MONEY = 50000;}void InitOIer(){OIer.push_back({"周康阳", "低", 100});OIer.push_back({"许琪文", "低", 100});OIer.push_back({"蒋凌宇", "低", 100});OIer.push_back({"邓明扬", "低", 100});}void Init(){InitMoney();InitOIer();}void Print(int WEEK){mycls();PrintTime(WEEK);PrintMoney();PrintOIer();}void GetMoney(int x){MONEY += x;}void GameLoop(int WEEK){Print(WEEK);if(MONEY > 10000){checkJ("请选择:\n1.训练 (-1000 $) 2.集训 (-10000 ~ " + to_string(MONEY) + " $) 3.比赛(开发中) 4.娱乐", "ALL", checkit);}else{checkJ("请选择:\n1.训练 (-1000 $) 2.集训 (-10000 $) 3.比赛(开发中) 4.娱乐", "ALL", checkit);}GetMoney(100);}void Story(){printH("[背景故事] 你是一名 OI 教练...", 100);cout << endl << endl;checkJ("( 输入任意字符以确认 )", "ALL", mycls);}int main(){srand(time(0));cout << "Welcome to OI 教 练 模 拟 器" << endl;cout << endl;checkJ("输入任意字符以开始游戏", "ALL", mycls);Story();Init();int WEEK = 0;while(++WEEK) GameLoop(WEEK);return 0;}```123456789101112131415V 0.4.1 版本将 `OIcoach.cpp` , `Library.h` 和 `Tools.h` 放在同一个文件夹内然后运行 `OIcoach.cpp` 即可.编译系统要求 C++17 及以上,Windows 系统.:::warning[如果你遇到中文乱码]请检查你的编辑器是否使用 UTF-8 编码保存文件。如果不是,可以向 AI 询问解决方法。:::[Tools.h](https://www.luogu.me/article/mxymkmrh)[Library.h](https://www.luogu.me/article/ugnc4dvz)[OIcoach.cpp](https://www.luogu.me/article/7p0n9ovf)