跳到正文

闲话

小学生做的游戏能有多好?

huangzhiyao约 31 分钟
原文
文章信息与版本

文章信息

发布
2026年4月26日
收录
2026年7月4日
更新
2026年10月10日
篇幅
约 31 分钟
获赞
1

版本

  1. v1当前

前记

我——作为一名6年级小学生(这没什么自豪的)终于写完了一个小~~游戏!!!

教师模拟器!

当然,我作为小学生,语法只会那么一点点,自然不能只靠自己了。。。。。。感谢D老师!

希望dalao帮我提提意见~

欢迎复制,打击抄袭!
本文章于2026年4月26日18:51编辑完成
2026年5月2日14:03进行微调


原程序

本蒟蒻的程序
C++
#include<cstdio>
#include<windows.h>
#include<conio.h>
#include<string>
#include<cstdlib>
#include<random>
#include<chrono>
#include<vector>
#include<cmath>
#include <algorithm>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string Name_database[100]={"double_2","alpha7","betaMax","cool_cat","dragon42","echo_1","falconX","gamma99","hero_123","ice_cream",
                           "joker_8","king_pin","lunar_22","matrix3","neo_01","omega_77","phoenix0","quantum9","rocket_5","shadow_11",
                           "titan_4","ultra_v","vector9","wolf_666","xenon_7","yellow6","zebra_2","astro_99","blaze_f","comet_8a",
                           "dark_04","eagle_1","frost_12","ghost_3","hyper_x","iron_man","jade_77","knight9","light_8","moon_22",
                           "nebula7","orion_5","pirate3","quake_1","raven_8","storm_6","thunder9","unity_2","viper_4","whale_0",
                           "xray_33","yeti_6","zenith7","atomic8","binary2","cobalt3","delta_7","ember_1","frosty5","glitch_9",
                           "hunter2","inferno","jolt_4","krypto1","laser_5","magnet6","nova_01","onyx_22","pixel_7","quasar8",
                           "ranger1","sigma_9","turbo_2","umbrella","vortex5","warp_99","xenith3","yonder7","zipper8","archon1",
                           "blitz_3","cipher9","drift_2","enigma0","flare_7","gadget4","havoc_5","impact3","jazz_1","karma_6",
                           "legend2","mirage8","ninja_0","outlaw7","phantom","quest_9","ripple5","saber_2","trick_4","uproar8"};
string Grade[9]={"D","C","B","A","S","SS","SSS","SSS+","QP"};
string School_name[180]={"未录取","未录取","未录取","未录取","未录取",
                         "未录取","未录取","未录取","未录取","未录取",
                         "未录取","未录取","未录取","未录取","未录取",
                         "未录取","未录取","未录取","未录取","未录取",
                         "未录取","未录取","未录取","未录取","未录取",
                         "未录取","未录取","未录取","未录取","未录取",
                         "未录取","未录取","未录取","未录取","未录取",
                         "未录取","未录取","未录取","未录取","未录取",
                         "未录取","未录取","未录取","未录取","未录取",
                         "未录取","未录取","未录取","未录取","未录取",
                         "深圳大学","深圳大学","浙江工业大学","浙江工业大学","南京工业大学",
                         "南京工业大学","燕山大学","燕山大学","扬州大学","江苏大学",
                         "福建师范大学","青岛大学","武汉科技大学","湖北大学","西安理工大学",
                         "上海理工大学","西安建筑科技大学","昆明理工大学","长春理工大学","山东科技大学",
                         "成都理工大学","东北财经大学","杭州电子科技大学","广东工业大学","浙江师范大学",
                         "上海师范大学","山东师范大学","长沙理工大学","西安科技大学","北方工业大学",
                         "首都经济贸易大学","南京邮电大学","重庆邮电大学","中国民航大学","西南政法大学",
                         "华东政法大学","河北大学","河南大学","山西大学","湘潭大学",
                         "南京信息工程大学","成都信息工程大学","天津工业大学","浙江理工大学","西安邮电大学",
                         "重庆交通大学","广州大学","济南大学","安徽师范大学","西北师范大学",
                         "兰州交通大学","东北石油大学","华侨大学","集美大学","北京邮电大学",
                         "对外经济贸易大学","北京科技大学","南京航空航天大学","上海财经大学","中央财经大学",
                         "北京交通大学","南京理工大学","西安电子科技大学","中国政法大学","华东理工大学",
                         "北京工业大学","天津医科大学","西南交通大学","哈尔滨工程大学","武汉理工大学",
                         "中国传媒大学","北京化工大学","中南财经政法大学","河海大学","东华大学",
                         "华中师范大学","苏州大学","暨南大学","西南财经大学","南京师范大学",
                         "华南师范大学","中国地质大学","西北大学","东北师范大学","北京林业大学",
                         "中国石油大学","合肥工业大学","南昌大学","郑州大学","湖南师范大学",
                         "云南大学","中国人民大学","北京航空航天大学","同济大学","北京师范大学",
                         "武汉大学","华中科技大学","南开大学","中山大学","东南大学",
                         "天津大学","厦门大学","四川大学","山东大学","西北工业大学",
                         "电子科技大学","华南理工大学","吉林大学","湖南大学","中南大学",
                         "重庆大学","大连理工大学","兰州大学","华东师范大学","中国农业大学",
                         "东北大学","中国海洋大学","中央民族大学","西北农林科技大学","哈尔滨工业大学",
                         "西安交通大学","南京大学","浙江大学","中国科学技术大学","上海交通大学",
                         "复旦大学","北京大学","清华大学","清华大学","清华大学"};
int score[9]={0,60,85,95,105,115,125,135,149};
int stamina,lastweek,money;
struct Mate{
	string name;
	int Chinese_score=0;
	string Chinese_grade;
	int Maths_score=0;
	string Maths_grade;
	int English_score=0;
	string English_grade;
	int Physics_score=0;
	string Physics_grade;
	int Chemistry_score=0;
	string Chemistry_grade;
	int Biology_score=0;
	string Biology_grade;
	int CEE_score=0;
	string CEE_grade;
}mate[6];
void Slowsay(const string& s){
	int l=s.size();
	for(int i=0;i<l;){
		int len=1;
        unsigned char c=s[i];
        if(c>=0xF0) len=4;
        else if(c>=0xE0) len=3;
        else if(c>=0xC0) len=2;
        printf("%.*s",len,&s[i]);
        fflush(stdout);
        i+=len;
        Sleep(1);
	}
	return;
}
void Class_Initialization(){
	vector<string> namePool;
    for(int i=0;i<100;i++) namePool.push_back(Name_database[i]);
	for(int i=0;i<6;i++){
		uniform_int_distribution<int> namedist(0,namePool.size()-1);
		int idx=namedist(rng);
		mate[i].name=namePool[idx];
		namePool.erase(namePool.begin()+idx);
		uniform_int_distribution<int> scoredist(5,40);
		mate[i].Chinese_score=scoredist(rng);
		mate[i].Maths_score=scoredist(rng);
		mate[i].English_score=scoredist(rng);
		mate[i].Physics_score=scoredist(rng);
		mate[i].Chemistry_score=scoredist(rng);
		mate[i].Biology_score=scoredist(rng);
	}
	return;
}
void Outputclass(){
	for(int i=0;i<6;i++){
		string out="学生"+mate[i].name+"\n";
    	out+="语文:"+mate[i].Chinese_grade+"\n";
    	out+="数学:"+mate[i].Maths_grade+"\n";
    	out+="英语:"+mate[i].English_grade+"\n";
    	out+="物理:"+mate[i].Physics_grade+"\n";
    	out+="化学:"+mate[i].Chemistry_grade+"\n";
    	out+="生物:"+mate[i].Biology_grade+"\n";
    	out+="\n";
    	Slowsay(out);
	}
	return;
}
void Resetgrade(){
	for(int i=0;i<6;i++){
		for(int j=0;j<=8;j++){
			if(mate[i].Chinese_score>=score[j]) mate[i].Chinese_grade=Grade[j];
		}
		for(int j=0;j<=8;j++){
			if(mate[i].Maths_score>=score[j]) mate[i].Maths_grade=Grade[j];
		}
		for(int j=0;j<=8;j++){
			if(mate[i].English_score>=score[j]) mate[i].English_grade=Grade[j];
		}
		for(int j=0;j<=8;j++){
			if(mate[i].Physics_score>=score[j]) mate[i].Physics_grade=Grade[j];
		}
		for(int j=0;j<=8;j++){
			if(mate[i].Chemistry_score>=score[j]) mate[i].Chemistry_grade=Grade[j];
		}
		for(int j=0;j<=8;j++){
			if(mate[i].Biology_score>=score[j]) mate[i].Biology_grade=Grade[j];
		}
	}
	return;
}
int CalcBonus(int curScore,int maxBonus){
    if (curScore>=150) return 0;
    int diff=150-curScore;
    int bonus=round(maxBonus*diff/150.0);
    bonus+=uniform_int_distribution<int>(-2,2)(rng);
    bonus=(std::max)(0,bonus);
    bonus=(std::min)(bonus,(150-curScore));
    return bonus;
}
int displayWidth(const string& s){
    int width=0;
    for(unsigned char c:s){
        if(c<0x80) width+=1;
        else width+=2;
    }
    return width;
}
string padRight(const string& s, int totalWidth){
    int cur=displayWidth(s);
    if(cur>=totalWidth) return s;
    return s+string(totalWidth-cur,' ');
}
void Outputresults(){
	uniform_int_distribution<int> dist(-5,5);
    Slowsay("学生姓名    语文  数学  英语  物理  化学  生物\n");
    for(int i=0;i<6;i++){
        string line;
        line+=padRight(mate[i].name,12);
        line+=padRight(to_string((std::min)(mate[i].Chinese_score+dist(rng),150)),6);
        line+=padRight(to_string((std::min)(mate[i].Maths_score+dist(rng),150)),6);
        line+=padRight(to_string((std::min)(mate[i].English_score+dist(rng),150)),6);
        line+=padRight(to_string((std::min)(mate[i].Physics_score+dist(rng),150)),6);
        line+=padRight(to_string((std::min)(mate[i].Chemistry_score+dist(rng),150)),6);
        line+=padRight(to_string((std::min)(mate[i].Biology_score+dist(rng),150)),6);
        Slowsay(line);
        Slowsay("\n");
    }
}
void wait(){
	Slowsay("按任意键继续...");
	_getch();
	system("cls");
}
void CEE(){
	Slowsay("学生姓名    语文  数学  英语  物理  化学  生物  总分\n");
	for(int i=0;i<6;i++){
		int CEEscore[6];
		string line;
		uniform_int_distribution<int> dist(-5,5);
		CEEscore[0]=(std::min)(mate[i].Chinese_score+dist(rng),150);
		CEEscore[1]=(std::min)(mate[i].Maths_score+dist(rng),150);
		CEEscore[2]=(std::min)(mate[i].English_score+dist(rng),150);
		CEEscore[3]=(std::min)(mate[i].Physics_score+dist(rng),150);
		CEEscore[4]=(std::min)(mate[i].Chemistry_score+dist(rng),150);
		CEEscore[5]=(std::min)(mate[i].Biology_score+dist(rng),150);
		int sum=0;
		for(int j=0;j<6;j++) sum+=CEEscore[j];
		int idx=sum/5;
		if(idx<0) idx=0;
		if(idx>179) idx=179;
		mate[i].CEE_grade=School_name[idx];
		mate[i].CEE_score=sum;
        line+=padRight(mate[i].name,12);
        line+=padRight(to_string(CEEscore[0]),6);
        line+=padRight(to_string(CEEscore[1]),6);
        line+=padRight(to_string(CEEscore[2]),6);
        line+=padRight(to_string(CEEscore[3]),6);
        line+=padRight(to_string(CEEscore[4]),6);
        line+=padRight(to_string(CEEscore[5]),6);
        line+=to_string(CEEscore[0]+CEEscore[1]+CEEscore[2]+CEEscore[3]+CEEscore[4]+CEEscore[5]);
        line+="/900";
        Slowsay(line+'\n');
	}
}
int main(){
	SetConsoleOutputCP(65001);
	SetConsoleCP(65001);
	Slowsay("欢迎来到教师模拟器\n\n");
	Slowsay("良心作者:黄智垚\n洛谷账号:huangzhiyao\n\n");
	wait();
	while(true){
		Class_Initialization();
		Resetgrade();
		lastweek=10,money=1000;
		while(lastweek!=0){
			money+=1000;
			stamina=3;
			char ch;
			do{
				system("cls");
				string out;
				out="距离高考还有 ";
				out+=to_string(lastweek);
				out+=" 周\n";
				out+="您的体力:";
				out+=to_string(stamina);
				out+="/3\n您的班费:";
				out+=to_string(money);
				out+="\n";
				Slowsay(out);
				Slowsay("您的班级:\n\n");
				Outputclass();
				Slowsay("请选择\n");
				Slowsay("1.自习:消耗一点体力,完成小量任务\n");
				Slowsay("2.课堂测:消耗一点体力,200班费,完成中量任务\n");
				Slowsay("3.试卷:消耗两点体力,500班费,完成大量任务\n");
				Slowsay("4.模拟测:消耗三点体力,1000班费,完成全部科目\n");
				Slowsay("5.结束本周\n");
				ch=_getch();
				while(ch<'1'||ch>'5'){
					Slowsay("未知输入!\n");
					ch=_getch();
				}
				int num=ch-48;
				switch(num){
					case 1:{
						if(stamina<1){
							Slowsay("体力不足,请重输\n");
							break;
						}else{
							stamina-=1;
							Slowsay("请选择\n");
							Slowsay("1.语英自习\n");
							Slowsay("2.数物自习\n");
							Slowsay("3.化生自习\n");
							char chn=_getch();
							while(chn<'1'||chn>'3'){
								Slowsay("未知输入!\n");
								chn=_getch();
							}
							int numn=chn-48;
							switch(numn){
								case 1:
									for(int i=0;i<6;i++){
										mate[i].Chinese_score+=CalcBonus(mate[i].Chinese_score,10);
										mate[i].English_score+=CalcBonus(mate[i].English_score,10);
									}
									break;
								case 2:
									for(int i=0;i<6;i++){
										mate[i].Maths_score+=CalcBonus(mate[i].Maths_score,10);
										mate[i].Physics_score+=CalcBonus(mate[i].Physics_score,10);
									}
									break;
								case 3:
									for(int i=0;i<6;i++){
										mate[i].Chemistry_score+=CalcBonus(mate[i].Chemistry_score,10);
										mate[i].Biology_score+=CalcBonus(mate[i].Biology_score,10);
									}
									break;
							}
						}
						wait();
						break;
					}
					case 2:{
						if(stamina<1){
							Slowsay("体力不足,请重输\n");
							break;
						}else if(money<200){
							Slowsay("班费不足,请重输\n");
							break;
						}else{
							stamina-=1;
							money-=200;
							Slowsay("请选择\n");
							Slowsay("1.语英小测\n");
							Slowsay("2.数物小测\n");
							Slowsay("3.化生小测\n");
							char chn=_getch();
							while(chn<'1'||chn>'3'){
								Slowsay("未知输入!\n");
								chn=_getch();
							}
							int numn=chn-48;
							switch(numn){
								case 1:
									for(int i=0;i<6;i++){
										mate[i].Chinese_score+=CalcBonus(mate[i].Chinese_score,15);
										mate[i].English_score+=CalcBonus(mate[i].English_score,15);
									}
									break;
								case 2:
									for(int i=0;i<6;i++){
										mate[i].Maths_score+=CalcBonus(mate[i].Maths_score,15);
										mate[i].Physics_score+=CalcBonus(mate[i].Physics_score,15);
									}
									break;
								case 3:
									for(int i=0;i<6;i++){
										mate[i].Chemistry_score+=CalcBonus(mate[i].Chemistry_score,15);
										mate[i].Biology_score+=CalcBonus(mate[i].Biology_score,15);
									}
									break;
							}
						}
						wait();
						break;
					}
					case 3:{
						if(stamina<2){
							Slowsay("体力不足,请重输\n");
							break;
						}else if(money<500){
							Slowsay("班费不足,请重输\n");
							break;
						}else{
							stamina-=2;
							money-=500;
							Slowsay("请选择\n");
							Slowsay("1.语文大考试\n");
							Slowsay("2.数学大考试\n");
							Slowsay("3.英语大考试\n");
							Slowsay("4.物理大考试\n");
							Slowsay("5.化学大考试\n");
							Slowsay("6.生物大考试\n");
							char chn=_getch();
							while(chn<'1'||chn>'6'){
								Slowsay("未知输入!\n");
								chn=_getch();
							}
							int numn=chn-48;
							switch(numn){
								case 1:
									for(int i=0;i<6;i++){
										mate[i].Chinese_score+=CalcBonus(mate[i].Chinese_score,30);
									}
									break;
								case 2:
									for(int i=0;i<6;i++){
										mate[i].Maths_score+=CalcBonus(mate[i].Maths_score,30);
									}
									break;
								case 3:
									for(int i=0;i<6;i++){
										mate[i].English_score+=CalcBonus(mate[i].English_score,30);
									}
									break;
								case 4:
									for(int i=0;i<6;i++){
										mate[i].Physics_score+=CalcBonus(mate[i].Physics_score,30);
									}
									break;
								case 5:
									for(int i=0;i<6;i++){
										mate[i].Chemistry_score+=CalcBonus(mate[i].Chemistry_score,30);
									}
									break;
								case 6:
									for(int i=0;i<6;i++){
										mate[i].Biology_score+=CalcBonus(mate[i].Biology_score,30);
									}
									break;
								}
						}
						wait();
						break;
					}
					case 4:{
						if(stamina<3){
							Slowsay("体力不足,请重输\n");
							break;
						}else if(money<1000){
							Slowsay("班费不足,请重输\n");
							break;
						}else{
							stamina-=3;
							money-=1000;
							Outputresults();
							for(int i=0;i<6;i++){
								mate[i].Chinese_score+=CalcBonus(mate[i].Chinese_score,30);
								mate[i].Maths_score+=CalcBonus(mate[i].Maths_score,30);
								mate[i].English_score+=CalcBonus(mate[i].English_score,30);
								mate[i].Physics_score+=CalcBonus(mate[i].Physics_score,30);
								mate[i].Chemistry_score+=CalcBonus(mate[i].Chemistry_score,30);
								mate[i].Biology_score+=CalcBonus(mate[i].Biology_score,30);
							}
							wait();
							break;
						}
					}
					case 5:{
						lastweek--;
						Slowsay("本周结束。\n");
						wait();
						break;
					}
				}
				Resetgrade();
			}while(ch!='5');
		}
		Slowsay("高考开始!\n\n");
		wait();
		CEE();
		int num_C9=0,num_985=0,num_211=0,num_no211=0;
		for(int i=0;i<6;i++){
			string s="";
			s=mate[i].name;
			s+="的学校:";
			s+=mate[i].CEE_grade;
			s+='\n';
			Slowsay(s);
			if(mate[i].CEE_score<249);
			else if(mate[i].CEE_score<599) num_no211++;
			else if(mate[i].CEE_score<749) num_211++;
			else if(mate[i].CEE_score<849) num_985++;
			else num_C9++;
		}
		if(num_C9==6) Slowsay("恭喜你,全员C9!\n");
		else if(num_C9+num_985==6) Slowsay("恭喜你,全员985!\n");
		else if(num_C9+num_985+num_211==6) Slowsay("恭喜你,全员211!\n");
		else if(num_C9+num_985+num_211+num_no211==6) Slowsay("恭喜你,全员上岸!\n");
		wait();
		Slowsay("按R再带一届学生!\n");
		char chh=_getch();
		if(chh!='R') break;
	}
	Slowsay("感谢游玩!!!");
	return 0;
}

后记

啊哈,真长

感谢D老师
给我一个关注吧!!!

原文
存档评论2 条抓取于