跳到正文

个人记录

OI教练模拟器[持续更新中]

_auto_约 21 分钟
原文

这是 2026年8月7日 存档的第 10 版,不是当前版本。查看当前版本

文章信息与版本
C++
// Copyright (C) since 2026 _auto_ / hwz007
// All rights reserved

// 编译系统要求 C++17 及以上,Windows 系统

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const string SAVE = "Copyright (C) since 2026 _auto_ / hwz007\nAll rights reserved\n\n";

const string NOW_V = "V 0.1.4\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"
};

const string PASSWORD = "PenaltyKingAKIOI";

struct _OIer{
    string name, happy;
    int good;
};
vector<_OIer> OIer;
int MONEY, WEEK; bool ISADMIN;

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 = "\n"; getline(cin, c);
    work(c);
    return t == "ALL" || c == t;
}

int checkJ(string s, string t, int work(string s)){
    cout << s << endl;
    string c = "\n"; getline(cin, c);
    return work(c);
}

string checkJ(string s, string t, string work(string s)){
    cout << s << endl;
    string c = "\n"; getline(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 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 Ka(){
    mycls();
    if(!ISADMIN)
        checkJ("请输入管理员密码: ", "ALL", checkPass);
    else
        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(){
    srand(time(0));
    InitMoney(); InitOIer();
}

void Print(){
    mycls();
    PrintTime(); PrintMoney(); PrintOIer();
}

void GameLoop(){
    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", 100);
    mypau("", mycls);
}

int main(){
    mypau("OI 教 练 模 拟 器\n\n", mycls);
    Story(); Init();
    while(++WEEK) GameLoop();
    return 0;
}