版本比较
OI教练模拟器[持续更新中]
正文
增加 9 行删除 403 行
12312534789101112561478910161112181920131422232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840915```cpp// Copyright (C) since 2026 _auto_ / hwz007// All rights reservedV 0.4.1 版本
// 编译系统要求 G++17 及以上,Windows 系统将 `OIcoach.cpp` , `Library.h` 和 `Tools.h` 放在同一个文件夹内然后运行 `OIcoach.cpp` 即可.
#include<bits/stdc++.h>#include<windows.h>#define endl '\n'using namespace std;typedef long long ll;typedef pair<int, int> pii;编译系统要求 C++17 及以上,Windows 系统.
string SAVE = "Copyright (C) since 2026 _auto_ / hwz007\nAll rights reserved\n\n";:::warning[如果你遇到中文乱码]请检查你的编辑器是否使用 UTF-8 编码保存文件。如果不是,可以向 AI 询问解决方法。:::
string NOW_V = "V 0.1.3\n\n";[Tools.h](https://www.luogu.me/article/mxymkmrh)
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"};[Library.h](https://www.luogu.me/article/ugnc4dvz)
struct _OIer{ string name, happy; int good;};vector<_OIer> OIer;int MONEY, WEEK;
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 mycls(string s = ""){system("cls");}
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 << 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);}
string checkJ(string s, string t, string 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游戏结束 !!\n", 100); if(rea == "money") printH("你破产了\n\n游戏结束 !!\n", 100); if(rea == "teacher") printH("你辞职了\n\n游戏结束 !!\n", 100); 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){ x = 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(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 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 < (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)) << endl << endl; Sleep(200); } checkOver(); mypau("", mycls);}
void Ji(){ int newMoney = MONEY; vector<_OIer> bx; for(auto [x, y, z] : OIer){ mycls(); cout << "请选择参加集训的人员 : " << endl << endl; cout << x << " 压力 : " << y << " 能力 : " << z << endl << endl; cout << "你希望 " << x << " 参加集训吗 ( 希望请输入 'Y' 或 'y' ) 预计剩余经费 : " << MONEY << " -> " << newMoney - 10000 << endl; 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 << 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 < (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)) << endl << endl; Sleep(200); break; } } checkOver(); mypau("", mycls);}
void Bi(){ mycls(); cout << "功能仍在开发中哟~" << endl << endl; mypau("", mycls); turnWeek();}
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 < (int)OIer.size(); i++){ auto [x, y, z] = OIer[i]; cout << x << " 压力 : " << OIer[i].happy << " -> " << (OIer[i].happy = changeLowHappy(y, 120)) << endl << endl; Sleep(200); } mypau("", mycls);}
void Ci(){ 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 << endl << endl; 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 << endl << endl; } checkJ("你要将谁的数据修改 ( 输入编号 ) : ", "ALL", ChangeOIer);}
void checkka(string s){ if(s == "1") KaMoney(); else if(s == "2") KaWEEK(); else if(s == "3") KaOIer(); turnWeek();}
void Ka(){ mycls(); checkJ("请选择要修改的数据 : \n1.MONEY 2.WEEK 3.OIer_data 4.退出", "ALL", checkka);}
void Ri(){ mycls(); cout << SAVE << "当前版本 : " << NOW_V; for(auto x : UPDATE_DAILY) cout << x; mypau("", mycls); turnWeek();}
void checkit(string s){ if(s == "1") Xun(); else if(s == "2") Ji(); else if(s == "3") Bi(); else if(s == "4") Yu(); else if(s == "5") Ci(); else if(s == "6") Ka(); else if(s == "7") Ri(); else turnWeek();}
void PrintTime(){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(){ mycls(); PrintTime(); PrintMoney(); PrintOIer();}
void GameLoop(){ Print(); if(MONEY > 10000) checkJ("请选择:\n1.训练 (-1000 $) 2.集训 (-10000 ~ " + to_string(MONEY) + " $) 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 教练...", 100); cout << endl << endl; mypau("", mycls);}
int main(){ srand(time(0)); cout << "Welcome to OI 教 练 模 拟 器" << endl << endl; mypau("", mycls); Story(); Init(); while(++WEEK) GameLoop(); return 0;}```[OIcoach.cpp](https://www.luogu.me/article/7p0n9ovf)