版本比较
OI教练模拟器[持续更新中]
正文
增加 9 行删除 596 行
1123456567878910101112131411121613141819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160215将 `OIcoach.cpp` 和 `Library.h` 放在同一个文件夹内然后运行 `OIcoach.cpp` 即可.V 0.4.1 版本
将 `OIcoach.cpp` , `Library.h` 和 `Tools.h` 放在同一个文件夹内然后运行 `OIcoach.cpp` 即可.
编译系统要求 C++17 及以上,Windows 系统.
Library.h :```cpp// Copyright (C) since 2026 _auto_ / hwz007// All rights reserved:::warning[如果你遇到中文乱码]请检查你的编辑器是否使用 UTF-8 编码保存文件。如果不是,可以向 AI 询问解决方法。:::
#include<bits/stdc++.h>#include<windows.h>using namespace std;typedef long long ll;typedef pair<int, int> pii;[Tools.h](https://www.luogu.me/article/mxymkmrh)
mt19937 mrand(time(0));[Library.h](https://www.luogu.me/article/ugnc4dvz)
class IORedirector{private: streambuf* old_cin_buf; streambuf* old_cout_buf; ifstream input_file; ofstream output_file; bool input_redirected; bool output_redirected;
public: explicit IORedirector(const string& in_file = "", const string& out_file = "") : old_cin_buf(nullptr), old_cout_buf(nullptr), input_redirected(false), output_redirected(false){
if(!in_file.empty()){ input_file.open(in_file); if(input_file.is_open()){ old_cin_buf = cin.rdbuf(input_file.rdbuf()); input_redirected = true; }else{ system("cls"); cout << "错误 : 找不到指定文件 " << in_file << "\n"; exit(0); } } if(!out_file.empty()){ output_file.open(out_file); if(output_file.is_open()){ old_cout_buf = cout.rdbuf(output_file.rdbuf()); output_redirected = true; } } }
~IORedirector(){ if(input_redirected && old_cin_buf){ cin.rdbuf(old_cin_buf); if(output_redirected && old_cout_buf){ cout.rdbuf(old_cout_buf); } } if(output_redirected && old_cout_buf){ cout.rdbuf(old_cout_buf); } } IORedirector(const IORedirector&) = delete; IORedirector& operator=(const IORedirector&) = delete;
IORedirector(IORedirector&& other) noexcept : old_cin_buf(other.old_cin_buf), old_cout_buf(other.old_cout_buf), input_redirected(other.input_redirected), output_redirected(other.output_redirected){ other.old_cin_buf = nullptr; other.old_cout_buf = nullptr; other.input_redirected = false; other.output_redirected = false; }};
const string SAVE = "Copyright (C) since 2026 _auto_ / hwz007\nAll rights reserved\n\n";
const string NOW_V = "V 0.3.0\n\n";
const vector<string> UPDATE_DAILY = { "V 0.1.1 更新内容 : \n 1. 优化了 \"集训\" 界面显示\n 2. 移除了彩蛋,并修复了无限刷钱的 Bug\n\n", "V 0.1.2 更新内容 : \n 1. 更好的操作系统\n\n", "V 0.1.3 更新内容 : \n 1. 优化代码架构,提升运行速度\n\n", "V 0.1.4 更新内容 : \n 1. 现在,打开调试工具需要管理员权限\n\n", "V 0.2.0 更新内容 : \n 1. 主界面会随机显示批话(摘自洛谷用户 dAniel_lele )\n\n", "V 0.3.0 更新内容 : \n 1. 新增存档功能,游戏内每周自动存档\n 2. 修复若干 Bug\n\n"};
const string PASSWORD = "PenaltyKingAKIOI";
const vector<string> BULLSHIT = { "\"当你在幻想上天会给你开一扇窗的时候,你已经输一半了\"", "\"不要害怕跟比自己强的人对线。当他已经无理到用自己的强弱来对线时,这个人已经无药可救了\"", "\"永远拿着早就不属于自己的能力在欺骗\"", "\"由俭入奢易,由奢入俭难。谁不曾幻想多当一会儿赢家呢,只是幻想永远是幻想罢了\"", "\"脑子不好是硬伤\"", "\"如果平时训练的时候没有压力每天摆烂从不从自己身上找原因,正式考完需要承担原本可以分摊到每天的压力\"", "\"有些事情,你没有必要对它有责任感,毕竟没有人对它有责任感\"", "\"戒一周游戏都戒不明白吗?\"", "\"让每一个时刻的你,不要成为另一个时刻的累赘。仅此而已\"", "\"活在这里…好累…如果上天不愿意让我活在一具能赢的躯体,能不能至少让我活在一具输了也不会难受的…\"", "\"因为别人比自己强而讨厌他/她是正常的吗…\"", "\"不要去思考未来,把这留给未来的你\"", "\"该认真一点了,他们已经超越你了,为什么还不端正态度?以前的你会因为这个天天夜夜破防,现在的你为何别得这般无耻?\"", "\"享受胜利就像吸毒,没有意义,容易上瘾,使人麻痹,无法持续\"", "\"为了守住友谊而看淡竞争,而不是为了看淡竞争而守住友谊\"", "\"你不能只在别人比你菜的时候才把别人当成朋友\"", "\"你羡慕啥呢?别人不过是学术比你强,脑子比你牛,天赋比你高,学习比你卷,干事效率比你高,进步比你快,性格比你好,人际关系比你好,情感比你赢,前途比你广,看不起你罢了,有什么好羡慕的呢?对吧?\"", "\"你不能只在你输的时候才想到要努力\"", "\"活着是干啥的是应该放在如何活着之前思考的吗?还是说都是毫不值得思考的问题\"", "\"把世界幻想得太简单,把自己幻想得太幸运\"", "\"日常做题过一个题理应与打比赛过一个题获得相同的成就感。别再执着于面子\"", "\"有过过去不代表会有未来\"", "\"又有谁会记住自己无心立下的承诺\"" "\"积极乐观,不意味着也不应基于忘却乃至回避那段不堪而屈辱的过去\"", "\"自信不应当靠虚伪成就\"", "\"不要为功利的一丝希望而活,你的人生不止有它,它也不配占据你活着的全部理由\"", "\"当你没能达到目标的时候,反思一下你定目标的能力\"", "\"渴望改变别人观点使别人认同自己是一件极度愚蠢且自负的行为\"", "\"运气在信息学竞赛中没有用,请不要为你水平菜找借口说运气不好\""};
struct _OIer{ string name, happy; int good;};vector<_OIer> OIer;int MONEY, WEEK;bool ISADMIN, ISNEW;string NOWSAVE;
void mycls(string s = ""){system("cls");}
int myToInt(string s){ int res = 0, f = 1; for(auto x : s){ if(x == '-') f = -1; else res = res * 10 + x - '0'; } return f * res;}
void GetMoney(int x){MONEY += x;}
void turnWeek(){WEEK--; GetMoney(-500);}
void NoworkVoid(string s){return;}
void mypau(string c, void work(string s) = NoworkVoid){cout << c; system("pause"); work("");}
int NoworkInt(string s){return 0;}
string NoworkString(string s){return "";}
string ReaRes(string s){return s;}
bool checkJ(string s, string t, void work(string s)){ cout << s << "\n"; string c = "\n"; getline(cin, c); work(c); return t == "ALL" || c == t;}
bool checkJ(string s, vector<string> t, void work(string s)){ cout << s << "\n"; string c = "\n"; getline(cin, c); work(c); for(auto x : t) if(c == x) return true; return t == (vector<string>){"ALL"};}
int checkJ(string s, string t, int work(string s)){ cout << s << "\n"; string c = "\n"; getline(cin, c); return work(c);}
string checkJ(string s, string t, string work(string s)){ cout << s << "\n"; string c = "\n"; getline(cin, c); return work(c);}
void printH(string s, int del){ for(auto x : s){ cout << x; Sleep(del); }}
void buildSave(string s){NOWSAVE = s + ".txt", ISNEW = true;}
void Save(string key = "SAVE"){ mycls(); IORedirector redirect("", NOWSAVE); cout << key << " "; cout << OIer.size() << " "; for(auto [x, y, z] : OIer){ cout << x << " " << y << " " << z << " "; } cout << MONEY << " " << WEEK << " " << ISADMIN << " ";}
void loadSave(string s){ NOWSAVE = s + ".txt"; IORedirector redirect(NOWSAVE, ""); string c; cin >> c; if(c == "OVER"){ mycls(); cout << "该存档游戏已结束,无法载入\n"; exit(0); }else if(c != "SAVE"){ mycls(); cout << "错误 : 文件 " << NOWSAVE << " 校验码错误,请检查它是否是你的游戏存档\n"; exit(0); } int n; cin >> n; OIer.clear(); for(int i = 1; i <= n; i++){ string x, y; int z; cin >> x >> y >> z; OIer.push_back({x, y, z}); } cin >> MONEY >> WEEK >> ISADMIN;}
void checkSave(string s){ mycls(); if(s == "1"){ checkJ("请输入新建存档名:", "ALL", buildSave); mypau("\n创建成功 !\n", mycls); Save(); }else if(s == "2"){ checkJ("请输入载入存档名:", "ALL", loadSave); mypau("\n载入成功 !\n", mycls); }}
void turnUTF(){system("chcp 65001");mycls();}
void PrintTime(){cout << "第 " << WEEK << " 周" << "\n\n";}
void PrintMoney(){cout << " 经费 : " << MONEY << " $\n\n";}
void PrintShit(){cout << BULLSHIT[mrand() % BULLSHIT.size()] << "\n\n\n";}
void PrintOIer(){ for(auto [x, y, z] : OIer){ cout << x << " 压力 : " << y << " 能力 : " << z << "\n\n"; }}
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(){ PrintTime(); PrintShit(); PrintMoney(); PrintOIer();}```OIcoach.cpp :```cpp// Copyright (C) since 2026 _auto_ / hwz007// All rights reserved
#include"library.h"
void GameOver(string rea){ cout << "\n"; if(rea == "student") printH("你没有了学员\n\n游戏结束 !!\n", 50); if(rea == "money") printH("你破产了\n\n游戏结束 !!\n", 50); if(rea == "teacher") printH("你辞职了\n\n游戏结束 !!\n", 50); mypau(""); Save("OVER"); exit(0);}
void AFO(string name){ cout << name << " 因为压力过大而退役" << "\n\n"; 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 "爆表"; 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 = mrand() % 100 + 1; if(rnd <= y) x = nxtHappy(x, name); return x;}
string changeLowHappy(string x, int y){ while(y > 100){ x = changeLowHappy(x, 100); y -= 100; } int rnd = mrand() % 100 + 1; if(rnd <= y) x = nxtLowHappy(x); return x;}
int changeGood(int x, int y){ int rnd = mrand() % 3 + 1; return x + y * rnd;}
void checkHappy(int mod){ bool canMod = false; while(true){ bool flag = false; for(auto [x, y, z] : OIer){ if(y == "爆表"){ flag = true, canMod = true; AFO(x); Sleep(300); break; } } if(!flag) break; } if(mod && canMod) mypau("", mycls);}
void checkMoney(){ if(MONEY < 0) GameOver("money");}
void checkOver(int mod = 0){ checkMoney(); checkHappy(mod);}
int checkPro(string s){return s[0] - '0';}
int calcProN(int x){return 20 * x - 10;}
int calcProG(int x){return 5 * x;}
void Training(){ mycls(); int cho = checkJ("请选择题目难度 : \n1.入门 2.普及- 3.普及/提高- 4.普及+/提高 5.提高+/省选- 6.省选/NOI- 7.NOI/NOI+/CTSC", "ALL", checkPro); while(cho < 1 || cho > 7){ mycls(); 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 << "\n"; Sleep(300); mycls(); } cout << "训练完成 !" << "\n\n"; cout << "训练结果 :" << "\n\n"; cout << "经费 : " << MONEY << " -> " << (MONEY -= 1000) << "\n\n"; Sleep(500); for(int i = 0; i < (int)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)) << "\n\n"; Sleep(200); } checkOver(); mypau("", mycls);}
void Camp(){ int newMoney = MONEY; vector<_OIer> bx; for(auto [x, y, z] : OIer){ mycls(); cout << "请选择参加集训的人员 : " << "\n\n"; cout << x << " 压力 : " << y << " 能力 : " << z << "\n"; cout << "你希望 " << x << " 参加集训吗 ( 希望请输入 'Y' 或 'y' ) 预计剩余经费 : " << MONEY << " -> " << newMoney - 10000 << "\n"; string cho = checkJ("", "ALL", ReaRes); if(cho == "Y" || cho == "y"){ 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 << "\n"; Sleep(300); mycls(); } cout << "集训完成 !" << "\n\n"; cout << "集训结果 :" << "\n\n"; cout << "经费 : " << MONEY << " -> " << (MONEY = newMoney) << "\n\n"; Sleep(500); for(auto [x, y, z] : bx){ for(int i = 0; i < (int)OIer.size(); i++){ if(OIer[i].name != x) continue; cout << x << " 压力 : " << y << " -> " << (OIer[i].happy = changeHappy(y, 250, x)) << " 能力 : " << z << " -> " << (OIer[i].good = changeGood(z, 50)) << "\n\n"; Sleep(200); break; } } checkOver(); mypau("", mycls);}
void Competition(){ mycls(); cout << "功能仍在开发中哟~" << "\n"; mypau("", mycls); turnWeek();}
void Entertainment(){ mycls(); for(int i = 1; i <= 6; i++){ cout << "娱乐中"; for(int j = 1; j <= i % 3 + 1; j++) cout << "."; cout << "\n"; Sleep(300); mycls(); } cout << "娱乐完成 !" << "\n\n"; cout << "娱乐结果 :" << "\n"; for(int i = 0; i < (int)OIer.size(); i++){ auto [x, y, z] = OIer[i]; cout << x << " 压力 : " << OIer[i].happy << " -> " << (OIer[i].happy = changeLowHappy(y, 120)) << "\n\n"; Sleep(200); } mypau("", mycls);}
void Quit(){ mycls(); string cho = checkJ("确认辞职吗 ( 确认请输入 'Y' 或 'y' )", "ALL", ReaRes); if(cho == "Y" || cho == "y"){ mycls(); GameOver("teacher"); }else{ turnWeek(); }}
void ChangeMoney(string x){ MONEY = myToInt(x); mypau("\n修改完成 ! \n\n", mycls);}
void ChangeWeek(string x){ WEEK = myToInt(x); mypau("\n修改完成 ! \n\n", mycls);}
bool NotFindHappy(string s){ if(s == "低") return false; if(s == "中") return false; if(s == "高") return false; if(s == "极高") return false; if(s == "爆表") return false; return true;}
void ChangeOIer(string id){ mycls(); int zid = myToInt(id); if(zid < 1 || zid > (int)OIer.size()){ mypau("\n错误 : 未找到该 OIer\n\n", mycls); return; } cout << OIer[zid - 1].name << " 原压力 : " << OIer[zid - 1].happy << " 原能力 : " << OIer[zid - 1].good << "\n\n"; string newHappy = checkJ("\n你要将 " + OIer[zid - 1].name + " 的压力值改为 : ", "ALL", ReaRes); int newGood = myToInt(checkJ("\n你要将 " + OIer[zid - 1].name + " 的能力值改为 : ", "ALL", ReaRes)); if(NotFindHappy(newHappy)){ mypau("\n错误 : 压力值输入错误\n\n", mycls); return; } OIer[zid - 1].happy = newHappy; OIer[zid - 1].good = newGood; mypau("\n修改完成 ! \n\n", mycls); checkOver(1);}
void KaMoney(){ mycls(); checkJ("\n你要将 MONEY 修改为 : ", "ALL", ChangeMoney);}
void KaWEEK(){ mycls(); checkJ("\n你要将 WEEK 修改为 : ", "ALL", ChangeWeek);}
void KaOIer(){ mycls(); int cnt = 0; for(auto [x, y, z] : OIer){ cout << ++cnt << ". " << x << " 压力 : " << y << " 能力 : " << z << "\n\n"; } checkJ("你要将谁的数据修改 ( 输入编号 ) : ", "ALL", ChangeOIer);}
void checkka(string s){ if(s == "1") KaMoney(); else if(s == "2") KaWEEK(); else if(s == "3") KaOIer(); turnWeek();}
void checkPass(string s){ if(s == PASSWORD){ ISADMIN = true; mycls(); checkJ("请选择要修改的数据: \n1.MONEY 2.WEEK 3.OIer_data 4.退出", "ALL", checkka); }else{ mycls(); mypau("密码错误!\n\n", mycls); turnWeek(); }}
void Debug(){ mycls(); if(!ISADMIN) checkJ("请输入管理员密码: ", "ALL", checkPass); else checkJ("请选择要修改的数据: \n1.MONEY 2.WEEK 3.OIer_data 4.退出", "ALL", checkka);}
void Log(){ mycls(); cout << SAVE << "当前版本 : " << NOW_V; for(auto x : UPDATE_DAILY) cout << x; mypau("", mycls); turnWeek();}
void checkit(string s){ if(s == "1") Training(); else if(s == "2") Camp(); else if(s == "3") Competition(); else if(s == "4") Entertainment(); else if(s == "5") Quit(); else if(s == "6") Debug(); else if(s == "7") Log(); else turnWeek();}
void GameLoop(){ Save(); Print(); if(MONEY > 10000) checkJ("请选择:\n1.训练 (-1000 $) 2.集训 (-10000 ~ " + to_string(10000 * min(MONEY / 10000, (int)OIer.size())) + " $) 3.比赛(开发中) 4.娱乐 5.辞职 6.调试工具 7.更新日志", "ALL", checkit); else checkJ("请选择:\n1.训练 (-1000 $) 2.集训 (-10000 $) 3.比赛(开发中) 4.娱乐 5.辞职 6.调试工具 7.更新日志", "ALL", checkit); GetMoney(500); checkOver();}
void Story(){ printH("[背景故事] 你是一名 OI 教练...\n\n", 50); mypau("", mycls);}
int main(){ turnUTF(); mypau("OI 教 练 模 拟 器\n\n", mycls); while(!checkJ("请选择:\n1.新建存档 2.载入存档", (vector<string>){"1", "2"}, checkSave)) mycls(); if(ISNEW){ Story(); Init(); } while(++WEEK) GameLoop(); return 0;}```[OIcoach.cpp](https://www.luogu.me/article/7p0n9ovf)