C++数字炸弹小游戏(英文版) C数字炸弹小游戏(英文不好的不要玩)这是本蒟蒻的第一篇博客如果有其他想法作者的私信和该文的评论区永远向您敞开在此鸣谢XY_Lmf、XY_Yzy附上友链中文版XY_Yzy制作传送门更新日不固定目前暂已完结下个版本可能会加入人机对战那么……废话不多说上代码Beta1.2.2(最新版)修复了一些bug#includebits/stdc.h #includewindows.h using namespace std; struct player{ string name; int index; int score; }a[105]; bool cmp(player x,player y) { return x.score y.score || x.score y.score x.index y.index; } void Show(string s) { for(auto e : s) { cout e; Sleep(75); } } void punish() { int id rand() % 5 1; switch(id) { case 1 : Show(Say to the winner: I hate you!);break; case 2 : Show(Drinking a cup of water now.);break; case 3 : Show(Randomly hit a certain player. (Bad laugh...^_^));break; case 4 : Show(Please play this game again!); break; default : Show(Say to each player:I am a little stupid.); } } int play_knock() { int bomb (rand() % 100) 1; int left 1,right 100; int cnt 0; while(true) { Show(Min Number:); cout left; Show( Max Number:); cout right \n; int x; cin x; cnt ; if(x bomb) { system(cls); Show(You are dead.); cout endl; Sleep(1500); system(cls); break; } else if(x bomb) { Show(It is bigger than the bomb.); cout endl; right x right ? x : right; Sleep(500); system(pause); system(cls); } else if(x bomb) { Show(It is lower than the bomb.); cout endl; left x left ? x : left; Sleep(500); system(pause); system(cls); } } cout The number of times you have used is: cnt; Sleep(2000); return cnt; } void play_Boom(int n) { int bomb (rand() % 100) 1; int left 1,right 100; int index 1; while(true) { Show(Min Number:); cout left; Show( Max Number:); cout right \n; Show(a[index].name); Show(s choice is:); int x; cin x; cout endl; if(x bomb) { system(cls); Show(a[index].name); Show( is dead.); cout endl; Sleep(1500); system(cls); break; } else if(x bomb) { Show(It is bigger than the bomb.); cout endl; right x right ? x : right; Sleep(500); system(pause); system(cls); } else if(x bomb) { Show(It is lower than the bomb.); cout endl; left x left ? x : left; Sleep(500); system(pause); system(cls); } index ; if(index n) index 1; } Show(The loser of this game is:); Show(a[index].name); Sleep(2000); } int main(){ Show(Digital Bomb Game!); cout endl; Show( By:Xy Studio); cout endl; cout endl; cout endl; Show(version Number: Beta 1.2.2); cout endl; system(pause); system(cls); srand(time(0)); Show(Please input the number of players (1-50):); int n; cin n; system(cls); for(int i 1;i n;i ) { Show(Player); cout i endl; Show(name:); string s; cin s; a[i].index i; a[i].name s; cout endl; } system(cls); Show(Please choose the game mode(Knock or Boom):); string mode; cin mode; if(mode Knock) { system(cls); Sleep(500); for(int i 1;i n;i ) { Show(a[i].name); cout endl; Show(Ready..........Start!); system(cls); a[i].score play_knock(); system(cls); } sort(a 1,a n 1,cmp); Show( Score List: ); cout endl; for(int i 1;i n;i ) { cout i :; Show(a[i].name); int len a[i].name.size(); int nulllen 20 - len; for(int i 1;i nulllen;i ) { cout ; Sleep(75); } cout a[i].score endl; } cout \n; system(pause); system(cls); } else if(mode Boom) { system(cls); Show(Ready..........Start!); system(cls); play_Boom(n); system(cls); Show(Start randomly choosing the punishment..........); Sleep(500); system(cls); Show(The punishment to the loser is:); punish(); Sleep(2000); system(cls); } else { system(cls); Show(Input error!); Sleep(2000); return 0; } Show(Thank you for your play.The next version is currently under development.); cout endl; Sleep(2000); return 0; }Beta2.1.3版本最新版加入了喜闻乐见的单人模式需注意的是在第一次打开单人游戏或电脑中不存在archive.txt即无存档时不能在读档时选择“Yes”选项#includebits/stdc.h #includewindows.h using namespace std; struct players{ string name; int index; int score; }a[105]; struct Person{ string name; int rank; int score; }; bool cmp(players x,players y) { return x.score y.score || x.score y.score x.index y.index; } void Show(string s) { for(auto e : s) { cout e; Sleep(75); } } void punish() { int id rand() % 5 1; switch(id) { case 1 : Show(Say to the winner: I hate you!);break; case 2 : Show(Drinking a cup of water now.);break; case 3 : Show(Randomly hit a certain player. (Bad laugh...^_^));break; case 4 : Show(Please play this game again!); break; default : Show(Say to each player:I am a little stupid.); } } int play_knock() { int bomb (rand() % 100) 1; int left 1,right 100; int cnt 0; while(true) { Show(Min Number:); cout left; Show( Max Number:); cout right \n; int x; cin x; cnt ; if(x bomb) { system(cls); Show(You are dead.); cout endl; Sleep(1500); system(cls); break; } else if(x bomb) { Show(It is bigger than the bomb.); cout endl; right x right ? x : right; Sleep(500); system(pause); system(cls); } else if(x bomb) { Show(It is lower than the bomb.); cout endl; left x left ? x : left; Sleep(500); system(pause); system(cls); } } cout The number of times you have used is: cnt; Sleep(2000); return cnt; } void play_Boom(int n) { int bomb (rand() % 100) 1; int left 1,right 100; int index 1; while(true) { Show(Min Number:); cout left; Show( Max Number:); cout right \n; Show(a[index].name); Show(s choice is:); int x; cin x; cout endl; if(x bomb) { system(cls); Show(a[index].name); Show( is dead.); cout endl; Sleep(1500); system(cls); break; } else if(x bomb) { Show(It is bigger than the bomb.); cout endl; right x right ? x : right; Sleep(500); system(pause); system(cls); } else if(x bomb) { Show(It is lower than the bomb.); cout endl; left x left ? x : left; Sleep(500); system(pause); system(cls); } index ; if(index n) index 1; } Show(The loser of this game is:); Show(a[index].name); Sleep(2000); } string Ranks[11] {Ungrade , Newbie , Introductory , Better , Somewhat-Famous , Well-Known , Super , Famous-Forever , Worlds-No.1 , Cosmic-Level , Transcend Reality}; int need[11] {0 , 100 , 200 , 300 , 400 , 500 , 600 , 700 , 800 , 900 , 1000}; void Play_DIFF1(Person x) { int bomb (rand() % 100) 1; int left 1,right 100; int index 1; string Name ; while(true) { Show(Min Number:); cout left; Show( Max Number:); cout right \n; int choice; if(index % 2 1) { Show(x.name); Name x.name; Show(s choice is:); cin choice; if(choice left) choice left 1; if(choice right) choice right - 1; cout endl; } else { Show(Machines choice is:); Name Machine; choice (rand() % (right - left)) left; Sleep(500); if(choice left) choice left 1; if(choice right) choice right - 1; cout choice; cout \n; } if(choice bomb) { system(cls); Show(Name); Show( is dead.); cout endl; Sleep(1500); system(cls); break; } else if(choice bomb) { Show(It is bigger than the bomb.); cout endl; right choice right ? choice : right; Sleep(500); system(pause); system(cls); } else if(choice bomb) { Show(It is lower than the bomb.); cout endl; left choice left ? choice : left; Sleep(500); system(pause); system(cls); } index ; } if(Name x.name) { Sleep(500); cout You Lose\n; cout Your rank-score minus 5\n; x.score max(0 , x.score - 5); } else { Sleep(500); cout Congratulations!\n; cout You Win!!!\n; cout Your rank-score adds 10\n; x.score x.score 10; } system(pause); system(cls); return; } void Play_DIFF2(Person x) { int bomb (rand() % 100) 1; int left 1,right 100; int index 1; string Name ; while(true) { Show(Min Number:); cout left; Show( Max Number:); cout right \n; int choice; if(index % 2 1) { Show(x.name); Name x.name; Show(s choice is:); cin choice; cout endl; if(choice left) choice left 1; if(choice right) choice right - 1; } else { Show(Machines choice is:); Name Machine; int len right - left 1; int mid (left right) / 2; int offset rand() % (len / 4); int op rand() % 2; if(op 0) choice mid - offset; else choice mid offset; if(choice left) choice left 1; if(choice right) choice right - 1; Sleep(500); cout choice; cout \n; } if(choice bomb) { system(cls); Show(Name); Show( is dead.); cout endl; Sleep(1500); system(cls); break; } else if(choice bomb) { Show(It is bigger than the bomb.); cout endl; right choice right ? choice : right; Sleep(500); system(pause); system(cls); } else if(choice bomb) { Show(It is lower than the bomb.); cout endl; left choice left ? choice : left; Sleep(500); system(pause); system(cls); } index ; } if(Name x.name) { Sleep(500); cout You Lose\n; cout Your rank-score minus 10\n; x.score max(0 , x.score - 10); } else { Sleep(500); cout Congratulations!\n; cout You Win!!!\n; cout Your rank-score adds 25\n; x.score x.score 25; } system(pause); system(cls); return; } void Play_DIFF3(Person x) { int bomb (rand() % 100) 1; int left 1,right 100; int index 1; string Name ; while(true) { Show(Min Number:); cout left; Show( Max Number:); cout right \n; int choice; if(index % 2 1) { Show(x.name); Name x.name; Show(s choice is:); cin choice; cout endl; if(choice left) choice left 1; if(choice right) choice right - 1; } else { Show(Machines choice is:); Name Machine; int mid (left right) / 2; choice mid; if(choice left) choice left 1; if(choice right) choice right - 1; Sleep(500); cout choice; cout \n; } if(choice bomb) { system(cls); Show(Name); Show( is dead.); cout endl; Sleep(1500); system(cls); break; } else if(choice bomb) { Show(It is bigger than the bomb.); cout endl; right choice right ? choice : right; Sleep(500); system(pause); system(cls); } else if(choice bomb) { Show(It is lower than the bomb.); cout endl; left choice left ? choice : left; Sleep(500); system(pause); system(cls); } index ; } if(Name x.name) { Sleep(500); cout You Lose\n; cout Your rank-score minus 20\n; x.score max(0 , x.score - 20); } else { Sleep(500); cout Congratulations!\n; cout You Win!!!\n; cout Your rank-score adds 50\n; x.score x.score 50; } system(pause); system(cls); return; } void Up_To_Next_Level(Person x) { x.rank ; system(cls); system(color f6); Show( Congratulations! ! !\n); Show( You have risen in rank [); Show(Ranks[x.rank]); Show(]\n); Show(Good job! Keep moving on to the next level! ! !\n); system(pause); system(cls); system(color 07); } void P_VS_M(Person x) { while(true) { cout Name: x.name \n; cout Your Rank: Ranks[x.rank]; cout \n; cout Your Score: x.score; cout \n; cout You still need need[x.rank 1] - x.score scores to advance to the next level\n\n\n; Show(Please choose(Input 1 ~ 4):\n); cout 1. Difficulty_#1 (Winning will add 10 scores)\n; cout 2. Difficulty_#2 (Winning will add 25 scores)\n; cout 3. Difficulty_#3 (Winning will add 50 scores)\n; cout 4. Exit and Settle\n; int choice; cin choice; system(pause); system(cls); if(choice 1) Play_DIFF1(x); else if(choice 2) Play_DIFF2(x); else if(choice 3) Play_DIFF3(x); else if(choice 4) break; else { system(cls); Show(Input Error!!!\n); system(pause); system(cls); } while(x.score need[x.rank 1]) Up_To_Next_Level(x); while(x.score need[x.rank]) x.rank --; } } int main(){ Show(Digital Bomb Game!); cout endl; Show( By:Xy Studio); cout endl; cout endl; cout endl; Show(version Number: Beta 2.0.1); cout endl; system(pause); system(cls); srand(time(0)); Show(Please input the number of players (1-50):); int n; cin n; system(cls); if(n 1) { Person x; system(cls); Show(Load saved game? (Yes / No)\n); string s; cin s; system(pause); system(cls); if(s Yes) { freopen(archive.txt , r , stdin); cin x.name x.rank x.score; freopen(CON , r , stdin); cin.clear(); cin.sync(); Show(........Login Successful\n); system(pause); system(cls); } else { Show(Please input the name of your character:\n); cin x.name; x.rank 0; x.score 0; system(pause); system(cls); } P_VS_M(x); system(cls); Show(Do you want to archive? (Yes / No)\n); string ar; cin ar; if(ar Yes) { ofstream outFile(archive.txt); if (outFile.is_open()) { outFile x.name x.rank x.score; outFile.close(); } } Sleep(1000); system(cls); } else { for(int i 1;i n;i ) { Show(Player); cout i endl; Show(name:); string s; cin s; a[i].index i; a[i].name s; cout endl; } system(cls); Show(Please choose the game mode(Knock / Boom):); string mode; cin mode; if(mode Knock) { system(cls); Sleep(500); for(int i 1;i n;i ) { Show(a[i].name); cout endl; Show(Ready..........Start!); system(cls); a[i].score play_knock(); system(cls); } sort(a 1,a n 1,cmp); Show( Score List: ); cout endl; for(int i 1;i n;i ) { cout i :; Show(a[i].name); int len a[i].name.size(); int nulllen 20 - len; for(int i 1;i nulllen;i ) { cout ; Sleep(75); } cout a[i].score endl; } cout \n; system(pause); system(cls); } else if(mode Boom) { system(cls); Show(Ready..........Start!); system(cls); play_Boom(n); system(cls); Show(Start randomly choosing the punishment..........); Sleep(500); system(cls); Show(The punishment to the loser is:); punish(); Sleep(2000); system(cls); } else { system(cls); Show(Input error!); Sleep(2000); return 0; } } system(cls); Show(Thank you for your play.The next version is currently under development.); cout endl; Sleep(2000); return 0; }注意事项1.记得在编译器中加入代码-stdc11或-stdc14game.h别忘了加上game.h哦#includeiostream #includewindows.h #includestring #includerandom #includeclimits

相关新闻

最新新闻

C#全栈开发指南

C#全栈开发指南

.NET全栈开发的现代实践路径已经很清晰:后端用ASP.NET Core Web API构建服务,前端用Blazor实现C#驱动的交互界面,再用Docker和Kubernetes将整个系统打包部署成云原生微服务。下面按三个核心板块拆解。 ASP.NET Core Web API:后端服…

2026/8/26 16:51:34
韩语评论仇恨言论识别助力平台内容审核

韩语评论仇恨言论识别助力平台内容审核

网络匿名性在赋予言论自由的同时,也催生了基于性别、性取向等特征的仇恨与冒犯性言论。韩国娱乐新闻评论区曾因恶意评论引发社会悲剧,促使平台关闭评论功能,但根本问题仍需技术手段介入解决。Kaggle竞赛“Korean Hate Speech Detection”正是针对此社会议题,要求构建模型对…

2026/8/26 16:51:34
Agent记忆与规划模块设计

Agent记忆与规划模块设计

Agent 的记忆、规划、长任务容错和评估调试,是构建生产级智能体的核心骨架。下面我从四个模块逐一拆解其设计逻辑和实战方法。 ________________________________________ 一、记忆模块设计:从"金鱼"到"大象" Agent 的本质问题在于&…

2026/8/26 16:51:34
医学影像分类实战复盘 从课程赛题到可落地建模流程

医学影像分类实战复盘 从课程赛题到可落地建模流程

这道 Kaggle 课程赛虽然页面信息很少,但任务边界很清晰,核心是围绕医学影像完成分类建模,并用分类准确率检验结果。这样的题目很适合用来训练完整的视觉项目思路,因为真正的难点不在提交一次预测文件,而在于把数据理解、标签核对、验证设计和模型迭代串成一条可复现流程。…

2026/8/26 16:51:34
不可学习 ImageNet 二分类实战 从图像识别到训练数据投毒防御

不可学习 ImageNet 二分类实战 从图像识别到训练数据投毒防御

Unlearnable ImageNet 不是常规的二分类刷榜题,表面任务是区分两类图像,真正难点在于训练集已被不可学习扰动处理,模型很容易出现训练正常、泛化失效的情况。文章重点不放在网络堆叠,而放在如何理解受污染数据、建立可靠验证闭环,并验证防御策略是否真正有效。 这类题目的…

2026/8/26 16:51:34
规则挖掘不止决策树:五族方法怎么选?

规则挖掘不止决策树:五族方法怎么选?

决策树是主力,但不是唯一。实战挖规则有"五族方法",按场景选:树基类:单棵全树抽规则、序列覆盖、级联树——适合从数据自动找切割;评分卡 WOE 基:WOE 逻辑回归,把变量转 WOE 后做回归,得到可解释的评分卡——适合需要稳定分数的场景;专家修正类:专家硬规则 拒绝推断…

2026/8/26 16:46:34