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

相关新闻

Hyper-V虚拟机

Hyper-V虚拟机

注意别用ub26版本,会各种卡死,看后期是否能更新好, 先用24长期版本吧 本地window自带的远程工具进行远程桌面连接吧。 不要用键盘右侧的小键盘 创建网路前关闭宿主机的防火墙,并且用这个里面创建的网络https://blog.csdn.net/m0_37641835/article/detail…

2026/10/28 10:16:37 阅读更多 →
有刷偏心电机整改案例分享

有刷偏心电机整改案例分享

一、前言有刷电机是我们经常接触的整改对象,不论是车载应用还是消费类产品,这类电机的辐射噪声通常不会过高,整体来说比较容易处理。然而,一旦在电机转子上加载偏心轮,辐射噪声便会急剧上升,导致严重超标&a…

2026/11/16 6:26:52 阅读更多 →
REFramework 实战手册:从 dinput8.dll 注入到跑通第一个 Lua Mod

REFramework 实战手册:从 dinput8.dll 注入到跑通第一个 Lua Mod

REFramework 实战手册:从 dinput8.dll 注入到跑通第一个 Lua Mod 【免费下载链接】REFramework Mod loader, scripting platform, and VR support for all RE Engine games 项目地址: https://gitcode.com/GitHub_Trending/re/REFramework REFramework 是 RE…

2026/11/4 13:21:15 阅读更多 →

最新新闻

Electron桌面应用开发实战:从环境搭建到打包发布全流程

Electron桌面应用开发实战:从环境搭建到打包发布全流程

做前端这些年,我大部分时间都在跟浏览器标签页打交道,直到第一次把桌面应用跑起来,才发现原来自己一直被限制在地址栏和刷新按钮围起来的框框里。Electron这个词,最开始是在某段时间频繁出现在同事的讨论里,一个用HTML…

2026/11/15 5:13:35 阅读更多 →
滑盖智能锁T109深度解析:结构原理、安装调试与故障排查

滑盖智能锁T109深度解析:结构原理、安装调试与故障排查

简介:亚太天能T109滑盖智能锁产品说明书是一份PDF格式的官方技术文档,主要面向智能锁安装人员、终端用户及售后维护者,帮助快速掌握产品安装、配置与常见故障处理。全包仅1个PDF文件,大小4.37MB,内容结构清晰&#xff…

2026/11/15 5:13:35 阅读更多 →
PMSM弱磁控制原理与Simulink建模:高速AGV驱动系统设计指南

PMSM弱磁控制原理与Simulink建模:高速AGV驱动系统设计指南

上个月我在调试一台高速AGV的驱动系统,整车要求空载跑到8m/s,电机转速已经拉到额定点,驱动器的输出电压也顶到了母线电压极限附近。再往上踩速度指令,转速纹丝不动,三相电流反而开始震荡。那会儿我的第一反应就是&…

2026/11/15 5:13:35 阅读更多 →
C++核心知识点:从内存管理到STL的实战指南

C++核心知识点:从内存管理到STL的实战指南

C 这门语言我前前后后折腾了十几年,用它写过嵌入式驱动、做过游戏服务端,也搭过基础组件库。每次看到新人一头扎进"C 核心知识点"这个搜索词,我其实挺感慨的——这门语言的难点从来不是语法多,而是知识点之间的耦合太深…

2026/11/15 3:37:41 阅读更多 →
T109滑盖智能锁怎么装?安装调试与故障排查全攻略

T109滑盖智能锁怎么装?安装调试与故障排查全攻略

简介:亚太天能T109滑盖智能锁产品说明书以PDF格式发布,适合智能锁用户、安装人员与售后维修人员阅读。内容围绕T109系列指纹密码刷卡锁展开,先介绍前面板、后面板、锁体、机械钥匙、电池盒盖等部件名称与功能,再给出完整安装步骤&…

2026/11/15 4:18:38 阅读更多 →
LLM知识降熵:从信息垄断到理解权下放

LLM知识降熵:从信息垄断到理解权下放

你有没有过这种经历:翻开源码注释、论文摘要或者一份专业报告,每个字都认识,连在一起却像天书。想找人聊聊,身边要么没人懂,要么懂的懒得跟你解释。后来我试着把同一段内容丢给一个大语言模型,几秒钟之后&a…

2026/11/15 5:13:35 阅读更多 →

日新闻

周新闻

月新闻