C++数字炸弹小游戏(英文版)

发布时间:2026/8/26 16:16:35

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

相关新闻

【普通数组】LC 189.轮转数组

【普通数组】LC 189.轮转数组

2026/8/26 16:16:35

文章目录前言一、题目1、原题链接2、题目描述二、个人思路整理1、思路分析法1:三次翻转法法2:环状替换法法3:额外数组映射2、解题代码法1:三次翻转法法2:环状替换法法3:额外数组映射三、知识风暴前言 本专栏…

Linux --进程控制

Linux --进程控制

2026/8/26 16:06:35

进程的诞生&#xff1a;fork 与 vfork fork 函数初识 在Linux中&#xff0c;fork 是创建新进程的唯一方式&#xff08;从用户态视角看&#xff09;。它通过复制调用进程&#xff08;父进程&#xff09;来生成一个全新的进程&#xff08;子进程&#xff09;。 #include <u…

The Words in the Dictionary Are Arranged in Order: Understanding Alphabetization

The Words in the Dictionary Are Arranged in Order: Understanding Alphabetization

2026/8/26 16:06:35

&#x1f680; TL;DR – Key TakeawaysAlphabetization is the systematic arrangement of words based on the order of letters in the English alphabet (A-Z). It’s not just about memorizing A-B-C—it’s about understanding letter priority, case sensitivity, punc…

2026 年 AI Agent 框架横评:10 大框架优缺点对比 + 选型指南

2026 年 AI Agent 框架横评:10 大框架优缺点对比 + 选型指南

2026/8/26 18:26:40

本文由 GO FUNNY 出品。专注 AI Agent 协作方法论与开源工具深度解读。你想搭一个 AI agent&#xff0c;打开 GitHub 搜「agent framework」&#xff0c;按 star 排序&#xff0c;点进第一名&#xff0c;照着 quickstart 敲完&#xff0c;跑通了一个 demo——觉得这事稳了。然后…

信奥梯队选拔面试中如何评估学员的抗挫能力

信奥梯队选拔面试中如何评估学员的抗挫能力

2026/8/26 18:26:40

信奥梯队选拔面试中评估学员抗挫能力&#xff0c;核心是通过可控的“轻度受挫场景”&#xff0c;观察学员面对解题卡壳、思路错误时的真实反应&#xff0c;筛选出能适配信奥长期刷题、反复调试、赛事高压场景的优质苗子。 一、分层设计抗挫能力测试场景 1、‌预备梯队&#x…

★★★ 完全自动化!个人工作日志统计/效率分析工具 —— 时间都去哪了(TimeWhere)

★★★ 完全自动化!个人工作日志统计/效率分析工具 —— 时间都去哪了(TimeWhere)

2026/8/26 18:26:40

你是否也经历过这样的场景&#xff1f; 周五下午被要求交周报&#xff0c;你盯着屏幕发呆——这周到底干了什么&#xff1f;年终写总结&#xff0c;翻遍聊天记录和邮件&#xff0c;却凑不出一份像样的工作总结&#xff1b;每天下班时感觉"挺忙的"&#xff0c;回头一…

第13章 同人•同道 与扎尔的告别

第13章 同人•同道 与扎尔的告别

2026/8/26 18:26:40

六月的波士顿已经是初夏了。查尔斯河两岸的树全绿了&#xff0c;浓密的树冠在水面上投下一大片碎影&#xff0c;风一吹就碎成无数个移动的小块。悦儿站在洛根机场的出发大厅里&#xff0c;面前是扎尔拖着两个行李箱的背影。他的帆布包换了一个新的——旧的那个磨了太久&#xf…

氩弧焊量产工况可以使用节气装置吗?

氩弧焊量产工况可以使用节气装置吗?

2026/8/26 18:26:40

一、前言在MIG、TIG、MAG等主流氩弧焊量产工况中&#xff0c;氩气作为核心保护气体&#xff0c;直接决定焊缝成型质量与良品率。目前绝大多数焊接产线&#xff0c;无论人工工位还是自动化机器人工位&#xff0c;普遍采用固定流量恒压供气模式。这种传统供气方式技术门槛低、调试…

零基础入门python22:注册接口与密码哈希——为什么不能保存明文密码

零基础入门python22:注册接口与密码哈希——为什么不能保存明文密码

2026/8/26 18:16:40

零基础入门python22&#xff1a;注册接口与密码哈希——为什么不能保存明文密码一、上一篇课后练习讲解 给账目增加日期时使用 date 类型&#xff0c;并让数据库列建立索引&#xff1b;测试应创建两天数据&#xff0c;查询某一天只返回对应记录。日期过滤要使用范围或等值比较&…

[光学原理与应用-521]:对光的错误理解与纠偏

[光学原理与应用-521]:对光的错误理解与纠偏

2026/8/26 1:50:39

首先光是一种能量的载体和形态&#xff0c;宏观上观察到的光是由无数个微观的光量子组成的&#xff0c;每个光子在产生的瞬间&#xff0c;其在真空的空间中以确定不变的速度沿着一个初始的方向一直向前&#xff0c;在微观层面&#xff0c;每个光量子的运动轨迹是以波函数所展现…

SIP通话转接原理与REFER方法实战解析

SIP通话转接原理与REFER方法实战解析

2026/8/26 1:49:16

1. 通话转接不是“挂断再拨号”&#xff0c;而是SIP会话的动态重定向你有没有遇到过这样的场景&#xff1a;客服坐席A正在和客户通电话&#xff0c;突然需要把这通对话无缝转给专家坐席B&#xff0c;客户完全感知不到中间的断连——既没听到忙音&#xff0c;也没被要求重新拨号…

Kolla-ansible单节点OpenStack部署实战:从环境准备到排坑指南

Kolla-ansible单节点OpenStack部署实战:从环境准备到排坑指南

2026/8/26 17:50:58

1. 为什么选择Kolla-ansible来部署单节点OpenStack&#xff1f;如果你正在寻找一种能把OpenStack从“概念”快速变成“可用的实验环境”的方法&#xff0c;那么Kolla-ansible几乎是当前最主流、最省心的选择。我见过太多人卡在手动编译依赖、配置服务、处理版本冲突的泥潭里&am…

Python random 模块常用函数详解:从入门到实战

Python random 模块常用函数详解:从入门到实战

2026/8/26 0:05:45

目录 1. 引言2. 准备工作3. 基础随机函数4. 序列相关函数5. 随机种子与复现6. 实战案例7. 注意事项8. 常见问题与排查9. 总结 1. 引言 摘要&#xff1a; 本文系统介绍 Python 标准库 random 模块中最常用的随机数生成函数。内容涵盖基础随机函数&#xff08;random()、unifor…

Hermes接入团队协作后,我推翻了三个效率假设

Hermes接入团队协作后,我推翻了三个效率假设

2026/8/26 0:05:45

聊《Hermes真能提效吗&#xff1f;先看流程里最慢的那一步》之前&#xff0c;先说一句实在的&#xff1a;别急着背概念&#xff0c;先看它在真实项目里到底解决什么问题。摘要团队把 Hermes 接进项目三个月后&#xff0c;交付速度没有提升反而慢了。复盘后发现&#xff0c;最先…

免费AI大模型调教指南:打造专属网文写作助手

免费AI大模型调教指南:打造专属网文写作助手

2026/8/26 0:05:45

1. 先搞清楚“AI小说扩展模式”到底能帮你做什么如果你是一个刚开始写网文、或者卡在L3级别以下的作者&#xff0c;最头疼的可能是情节推进不下去、人物对话干瘪&#xff0c;或者世界观设定不够丰满。自己对着空白文档硬憋&#xff0c;效率很低。这时候&#xff0c;一个能理解你…

摆脱论文困扰!盘点2026年全网爆红的的AI论文写作工具

摆脱论文困扰!盘点2026年全网爆红的的AI论文写作工具

2026/8/22 2:02:26

一天写完毕业论文在2026年已不再是天方夜谭。2026年最炸裂、实测能大幅提速的AI论文写作工具&#xff0c;覆盖选题构思、文献整理、内容生成、格式排版等核心场景&#xff0c;真正帮你高效搞定论文难题。 一、全流程王者&#xff1a;一站式搞定论文全链路&#xff08;一天定稿首…

导师推荐!2026最新AI论文工具测评与实用推荐

导师推荐!2026最新AI论文工具测评与实用推荐

2026/8/26 18:07:30

2026年真正好用的AI论文工具&#xff0c;核心看生成的论文质量、低AI味、格式正确、学术适配四大指标。综合实测&#xff0c;千笔AI、ThouPen、豆包、DeepSeek、Grammarly 是当前最值得推荐的梯队&#xff0c;覆盖从免费到付费、从中文到英文、从文科到理工的全场景需求。 一、…

告别游戏崩溃:XCOM 2模组管理器的智能革命

告别游戏崩溃:XCOM 2模组管理器的智能革命

2026/8/26 17:57:52

告别游戏崩溃&#xff1a;XCOM 2模组管理器的智能革命 【免费下载链接】xcom2-launcher The Alternative Mod Launcher (AML) is a replacement for the default game launchers from XCOM 2 and XCOM Chimera Squad. 项目地址: https://gitcode.com/gh_mirrors/xc/xcom2-lau…