当前位置:   article > 正文

C语言游戏实战(4):人生重开模拟器_c++人生重开模拟器

c++人生重开模拟器

 前言:

人生重开模拟器是前段时间非常火的一个小游戏,接下来我们将一起学习使用c语言写一个简易版的人生重开模拟器。 

网页版游戏:

人生重开模拟器 (ytecn.com)

1.实现一个简化版的人生重开模拟器

(1) 游戏开始的时候,设定初始属性:颜值,体质,智力,家境

(2)开始游戏,随机生成性别和出生点

(3)针对每一年生成一些人生的经历(依靠一定的随机因素+当前角色的属性)

2.打印菜单

  1. void menu()
  2. {
  3. printf("---------------------------------------------------\n");
  4. printf("| |\n");
  5. printf("| 欢迎来到人生重开模拟器 |\n");
  6. printf("| 1.play |\n");
  7. printf("| 2.exit |\n");
  8. printf("| |\n");
  9. printf("---------------------------------------------------\n");
  10. }
  11. void game()
  12. {
  13. }
  14. int main()
  15. {
  16. int input = 0;
  17. do
  18. {
  19. menu();
  20. printf("请选择>:");
  21. scanf("%d", &input);
  22. switch (input)
  23. {
  24. case 1:
  25. game();
  26. break;
  27. case 0:
  28. printf("退出游戏\n");
  29. break;
  30. default:
  31. printf("选择错误,请重新选择\n");
  32. }
  33. } while (input);
  34. return 0;
  35. }

3.设置初始属性

(1)颜值,体制,智力,家境,总和不能超过20,每一项取值都是1-10之间

  1. printf("请设置初始属性(可用点数总数为 20)>:\n");
  2. printf("请输入颜值(1-10):");
  3. scanf("%d", &face);
  4. printf("请输入体质(1-10):");
  5. scanf("%d", &strong);
  6. printf("请输入智力(1-10):");
  7. scanf("%d", &iq);
  8. printf("请输入家境(1-10):");
  9. scanf("%d", &home);

(2)对用户输入的内容进行校验

可以写一个while循环,如果玩家输入正确结束循环,反之循环继续。这里我们可以取标记值count=1,如果玩家输入无误只需count-1=0就可以跳出循环了,反之count+1继续循环。

  1. int face = 0, strong = 0, iq = 0, home = 0;
  2. int count = 1;
  3. while (count)
  4. {
  5. printf("请设置初始属性(可用点数总数为 20)>:\n");
  6. printf("请输入颜值(1-10):");
  7. scanf("%d", &face);
  8. printf("请输入体质(1-10):");
  9. scanf("%d", &strong);
  10. printf("请输入智力(1-10):");
  11. scanf("%d", &iq);
  12. printf("请输入家境(1-10):");
  13. scanf("%d", &home);
  14. if (face > 10 || face < 1 || strong>10 || strong < 1 || iq>10 || iq < 1 || home>10 || home < 1)
  15. {
  16. printf("属性点输入有误,请重新输入\a\n");
  17. count++;
  18. }
  19. else if (face + strong + iq + home > 20)
  20. {
  21. printf("属性总和大于20,请重新输入\a\n");
  22. count++;
  23. }
  24. count--;
  25. }
  26. printf("初始属性输入完毕!\n");
  27. printf("颜值:%d,体质:%d,智力:%d,家境:%d\n", face, strong, iq, home);

4.生成角色的性别

利用rand函数srand函数time函数生成一个随机数,就可以间接的随机生成一个性别了。

  1. #include<stdio.h>
  2. #include<time.h>
  3. #include<stdlib.h>
  4. srand((unsigned int)time(NULL));
  5. int sex = rand() % 2;
  6. if (sex == 1)
  7. {
  8. printf("你是个男孩.\n");
  9. }
  10. else
  11. {
  12. printf("你是个女孩.\n");
  13. }

5.设置角色的出生点

大致思路:

家境 10 第一档,带来一些属性的加成

家境 7-9 第二档,也会带来属性的加成

家境 4-6 第三档,少数属性加成

家境 1-3 第四档,会扣属性

每一个档又通过随机数分为三种情况。

  1. int point = rand() % 3;
  2. //第一档
  3. if (home == 10)
  4. {
  5. printf("你出生在帝都,你的父母是高管政要.\n");
  6. home += 1;
  7. iq += 1;
  8. face += 1;
  9. }
  10. //第二档
  11. else if (home <= 9 && home >= 7)
  12. {
  13. if (point == 1)
  14. {
  15. printf("你出生在大城市,你的父母是公务员.\n");
  16. face += 2;
  17. }
  18. else if (point == 2)
  19. {
  20. printf("你出生在大城市,你的父母是企业高管.\n");
  21. home += 2;
  22. }
  23. else
  24. {
  25. printf("你出生在大城市,你的父母是大学教授.\n");
  26. iq += 2;
  27. }
  28. }
  29. //第三档
  30. else if (home <= 6 && home >= 4)
  31. {
  32. if (point == 1)
  33. {
  34. printf("你出生在三线城市,你的父母是医生.\n");
  35. strong += 1;
  36. }
  37. else if (point == 2)
  38. {
  39. printf("你出生在镇上,你的父母是老师.\n");
  40. iq += 1;
  41. }
  42. else
  43. {
  44. printf("你出生在镇上,你的父母是个体户.\n");
  45. home += 1;
  46. }
  47. }
  48. //第四档
  49. else
  50. {
  51. if (point == 1)
  52. {
  53. printf("你出生在农村,你的父母是辛苦劳作的农民.\n");
  54. strong += 1;
  55. face -= 2;
  56. }
  57. else if (point)
  58. {
  59. printf("你出生在穷乡僻壤,你的父母是无业游民.\n");
  60. home -= 1;
  61. }
  62. else
  63. {
  64. printf("你出生在镇上,你的父母感情不和.\n");
  65. strong -= 1;
  66. }
  67. }
  68. printf("颜值:%d,体质:%d,智力:%d,家境:%d\n", face, strong, iq, home);

6.幼年阶段(1-10岁)

大致思路:

先使用for循环,按照年龄,从1循环到10

针对每一年,都生成一个随机数(1-3)

根据角色,心别,年龄,各种属性,触发各种事件,随机数会对事件的结果造成影响

这里的事件可能会对属性带来变更

每一年执行结束,都打印这一年发生的事件(让每年只发生一个事件)

也可能会遇到夭折的情况

代码难点:

1.利用结构题数组给数组赋值字符串:

其中利用了strcpy函数,需要使用#include<string.h>对它进行调用。

2.让一些事件重复执行

这里利用了switch语句,和while循环,以及rand函数srand函数time函数生成随机数。

因为这里只是打印1-10岁的事件,所以我在这里给count赋值了一个10然后count--,这样就可以循环打印1-10岁了,再然后我在这里利用了随机数,使其随机在我写好的事件中选一个事件打印。

3.打印的时候可以打印得慢一点

我在这里使用了Sleep函数,需要使用#include<windows.h>对它进行调用。

4.为了丰富故事内容,我在里面加入了类似于的新闻的事件,且这种事件与受人物属性影响的事件的不同点是:1.这个事件不受人物属性的影响,也不能影响人物属性,它的产生是随机的。2.这个事件只能执行(打印)一次,而受人物属性影响的事件可以执行多次。

这里的难点是如何让这种新闻性的事件不重复执行。我在这里用到了goto语句,先赋值一个元素为0,执行一次之后使其加1,然后通过if语句判断,如果赋值的那个元素已经不等于零,则执行goto语句,使其重新生成一个随机数,和重新执行switch语句。

  1. struct Event
  2. {
  3. char eve[80];
  4. };
  5. void even(int face,int strong,int iq,int home,int sex,int point)
  6. {
  7. srand((unsigned int)time(NULL));
  8. int t = 0, o = 0, w = 0, r = 0, f = 0, v = 0, s = 0, e = 0, n = 0, g = 0;
  9. int count = 10;
  10. int age = 1;
  11. while (count)
  12. {
  13. int a = rand() % 10;
  14. struct Event arr[10];
  15. again:
  16. switch (a + 1)
  17. {
  18. case 1:
  19. if (sex == 0 && home <= 3 && point == 1)
  20. {
  21. strcpy(arr[0].eve, "你的家里人重男轻女观念非常严重,你被遗弃了!\n游戏结束!");
  22. printf("%s\n", arr[0].eve);
  23. count = 1;
  24. }
  25. else
  26. {
  27. if (o == 0)
  28. {
  29. strcpy(arr[0].eve, "全球范围实现碳中和。");
  30. o++;
  31. }
  32. else
  33. {
  34. a = rand((unsigned int)time(NULL)) % 10;
  35. goto again;
  36. }
  37. }
  38. break;
  39. case 2:
  40. if (strong < 6 && point < 3)
  41. {
  42. if (home >= 5)
  43. {
  44. strcpy(arr[1].eve, "你生了一场病,在你的父母悉心照顾下,你康复了");
  45. strong += 1;
  46. home -= 1;
  47. }
  48. else
  49. {
  50. strcpy(arr[1].eve, "你生了一场病,你的父母没精力管你,你的身体状况更糟糕了");
  51. strong -= 1;
  52. }
  53. }
  54. else
  55. {
  56. if (w == 0)
  57. {
  58. strcpy(arr[1].eve, "火星建立永久性人类居住基地。");
  59. w++;
  60. }
  61. else
  62. {
  63. a = rand() % 10;
  64. goto again;
  65. }
  66. }
  67. break;
  68. case 3:
  69. if (face <= 4&& age >= 7)
  70. {
  71. if (iq > 5)
  72. {
  73. strcpy(arr[2].eve, "你长得太丑了,别的小朋友不喜欢你,你决定用学习填充自己");
  74. }
  75. else
  76. {
  77. if (sex == 1)
  78. {
  79. strcpy(arr[2].eve, "你长得太丑了,别的小朋友不喜欢你,你和别的小朋友经常打架!");
  80. strong += 1;
  81. iq -= 1;
  82. }
  83. else
  84. {
  85. strcpy(arr[2].eve, "你长得太丑了,别的小朋友不喜欢你,你进常被被别的小朋友欺负");
  86. strong -= 1;
  87. }
  88. }
  89. }
  90. else
  91. {
  92. if (r == 0)
  93. {
  94. strcpy(arr[2].eve, "全球范围内的无人驾驶汽车技术普及。");
  95. r++;
  96. }
  97. else
  98. {
  99. a = rand() % 10;
  100. goto again;
  101. }
  102. }
  103. break;
  104. case 4:
  105. if (iq < 5)
  106. {
  107. if (home >= 8 && age >= 6)
  108. {
  109. strcpy(arr[3].eve, "你看起来傻傻的,你的父母把你送到更好的学校学习。");
  110. iq += 1;
  111. }
  112. else if (home >= 4 && home <= 7)
  113. {
  114. if (sex == 1)
  115. {
  116. strcpy(arr[3].eve, "你看起来傻傻的,你的父母鼓励你多运动,争取成为运动员。");
  117. strong += 1;
  118. }
  119. else
  120. {
  121. strcpy(arr[3].eve, "你看起来傻傻的,你的父母鼓励你多打扮自己。");
  122. face += 1;
  123. }
  124. }
  125. else
  126. {
  127. strcpy(arr[3].eve, "你看起来傻傻的,你的父母为此经常吵架。");
  128. if (point == 1)
  129. strong -= 1;
  130. else if (point == 2)
  131. iq -= 1;
  132. }
  133. }
  134. else
  135. {
  136. if (f == 0)
  137. {
  138. strcpy(arr[3].eve, "人工智能与人类共同创造新文化。");
  139. f++;
  140. }
  141. else
  142. {
  143. a = rand() % 10;
  144. goto again;
  145. }
  146. }
  147. break;
  148. case 5:
  149. {
  150. if (point == 1)
  151. {
  152. strcpy(arr[4].eve, "你健康成长,你看起来更结实了。");
  153. strong += 1;
  154. }
  155. else if (point == 2)
  156. {
  157. strcpy(arr[4].eve, "你健康成长,你看起来更好看了。");
  158. face += 1;
  159. }
  160. else
  161. {
  162. if (v == 0)
  163. {
  164. strcpy(arr[4].eve, "人类开始探索宇宙深处,与外星文明建立联系。");
  165. v++;
  166. }
  167. else
  168. {
  169. a = rand() % 10;
  170. goto again;
  171. }
  172. }
  173. }
  174. break;
  175. case 6:
  176. if (s == 0)
  177. {
  178. strcpy(arr[5].eve, "人类成功实现核聚变能源的商业化应用,彻底解决能源危机问题。");
  179. s++;
  180. }
  181. else
  182. {
  183. a = rand() % 10;
  184. goto again;
  185. }
  186. break;
  187. case 7:
  188. if (e == 0)
  189. {
  190. strcpy(arr[6].eve, "虚拟实现技术发展到一个全新的高度,人们可以随时地沉浸到虚拟世界中。");
  191. e++;
  192. }
  193. else
  194. {
  195. a = rand() % 10;
  196. goto again;
  197. }
  198. break;
  199. case 8:
  200. if (n == 0)
  201. {
  202. strcpy(arr[7].eve, "全球范围内的高速交通网络初步建成,人们可以在几小时内穿越地球。");
  203. n++;
  204. }
  205. else
  206. {
  207. a = rand() % 10;
  208. goto again;
  209. }
  210. break;
  211. case 9:
  212. if (g == 0)
  213. {
  214. strcpy(arr[8].eve, "高考取消英语这门科目。");
  215. g++;
  216. }
  217. else
  218. {
  219. a = rand() % 10;
  220. goto again;
  221. }
  222. break;
  223. case 10:
  224. if (t == 0)
  225. {
  226. strcpy(arr[9].eve, "全球实现无国界教育,世界各地的学生都能接受优质的教育。");
  227. t++;
  228. }
  229. else
  230. {
  231. a = rand() % 10;
  232. goto again;
  233. }
  234. break;
  235. }
  236. if (strong <= 0)
  237. {
  238. printf("你今年 %d 岁\n", age);
  239. if (point == 1)
  240. {
  241. printf("你染上了新冠病毒,没能抗住病毒的侵袭,你死了!\n");
  242. printf("游戏结束!\n");
  243. break;
  244. }
  245. else if (point == 2)
  246. {
  247. printf("你得了白血病,不幸去世!\n");
  248. printf("游戏结束!\n");
  249. break;
  250. }
  251. else
  252. {
  253. printf("你吃东西的时候不小心被呛死了!\n");
  254. printf("游戏结束!\n");
  255. break;
  256. }
  257. }
  258. else if (iq <= 0)
  259. {
  260. printf("你今年 %d 岁\n", age);
  261. if (point == 1)
  262. {
  263. printf("你发高烧的时候,由于治疗不及时变成了一个智障!\n");
  264. printf("游戏结束!\n");
  265. break;
  266. }
  267. else if (point == 2)
  268. {
  269. printf("你不小心喝了日本核污水变成了一个智障!\n");
  270. printf("游戏结束!\n");
  271. break;
  272. }
  273. else
  274. {
  275. printf("由于酒精中毒,你变成了一个智障\n");
  276. printf("游戏结束!\n");
  277. break;
  278. }
  279. }
  280. printf("---------------------------------------------------------------\n");
  281. printf("你今年 %d 岁了\n", age);
  282. printf("%s\n", arr[a].eve);
  283. printf("颜值:%d,体质:%d,智力:%d,家境:%d\n", face, strong, iq, home);
  284. printf("---------------------------------------------------------------\n");
  285. Sleep(1000);
  286. age++;
  287. count--;
  288. }
  289. }

7.其他年龄段:

 如果你感兴趣的话,你可以充分发挥你的想象力,将其他年龄段的事件完善完善,例如在某个年龄段觉醒了修仙天赋,从此脱离凡尘,步入仙境;再比如在某个年龄段接触了电子竞技,对游戏的天赋极高,成为了一个职业玩家。

完整代码:

  1. #define _CRT_SECURE_NO_WARNINGS 1
  2. #include<stdio.h>
  3. #include<time.h>
  4. #include<stdlib.h>
  5. #include<windows.h>
  6. #include<string.h>
  7. void menu()
  8. {
  9. printf("---------------------------------------------------\n");
  10. printf("| |\n");
  11. printf("| 欢迎来到人生重开模拟器 |\n");
  12. printf("| 1.play |\n");
  13. printf("| 2.exit |\n");
  14. printf("| |\n");
  15. printf("---------------------------------------------------\n");
  16. }
  17. struct Event
  18. {
  19. char eve[80];
  20. };
  21. void even(int face, int strong, int iq, int home, int sex, int point);
  22. void game()
  23. {
  24. srand((unsigned int)time(NULL));
  25. //输入初始属性
  26. int face = 0, strong = 0, iq = 0, home = 0;
  27. int count = 1;
  28. while (count)
  29. {
  30. printf("请设置初始属性(可用点数总数为 20)>:\n");
  31. printf("请输入颜值(1-10):");
  32. scanf("%d", &face);
  33. printf("请输入体质(1-10):");
  34. scanf("%d", &strong);
  35. printf("请输入智力(1-10):");
  36. scanf("%d", &iq);
  37. printf("请输入家境(1-10):");
  38. scanf("%d", &home);
  39. if (face > 10 || face < 1 || strong>10 || strong < 1 || iq>10 || iq < 1 || home>10 || home < 1)
  40. {
  41. printf("属性点输入有误,请重新输入\a\n");
  42. count++;
  43. }
  44. else if (face + strong + iq + home > 20)
  45. {
  46. printf("属性总和大于20,请重新输入\a\n");
  47. count++;
  48. }
  49. count--;
  50. }
  51. printf("初始属性输入完毕!\n");
  52. printf("颜值:%d,体质:%d,智力:%d,家境:%d\n", face, strong, iq, home);
  53. //生成角色的性别
  54. int sex = rand() % 2;
  55. if (sex == 1)
  56. {
  57. printf("你是个男孩.\n");
  58. }
  59. else
  60. {
  61. printf("你是个女孩.\n");
  62. }
  63. //设定角色的出生点
  64. int point = rand() % 3;
  65. //第一档
  66. if (home == 10)
  67. {
  68. printf("你出生在帝都,你的父母是高管政要.\n");
  69. home += 1;
  70. iq += 1;
  71. face += 1;
  72. }
  73. //第二档
  74. else if (home <= 9 && home >= 7)
  75. {
  76. if (point == 1)
  77. {
  78. printf("你出生在大城市,你的父母是公务员.\n");
  79. face += 2;
  80. }
  81. else if (point == 2)
  82. {
  83. printf("你出生在大城市,你的父母是企业高管.\n");
  84. home += 2;
  85. }
  86. else
  87. {
  88. printf("你出生在大城市,你的父母是大学教授.\n");
  89. iq += 2;
  90. }
  91. }
  92. //第三档
  93. else if (home <= 6 && home >= 4)
  94. {
  95. if (point == 1)
  96. {
  97. printf("你出生在三线城市,你的父母是医生.\n");
  98. strong += 1;
  99. }
  100. else if (point == 2)
  101. {
  102. printf("你出生在镇上,你的父母是老师.\n");
  103. iq += 1;
  104. }
  105. else
  106. {
  107. printf("你出生在镇上,你的父母是个体户.\n");
  108. home += 1;
  109. }
  110. }
  111. //第四档
  112. else
  113. {
  114. if (point == 1)
  115. {
  116. printf("你出生在农村,你的父母是辛苦劳作的农民.\n");
  117. strong += 1;
  118. face -= 2;
  119. }
  120. else if (point)
  121. {
  122. printf("你出生在穷乡僻壤,你的父母是无业游民.\n");
  123. home -= 1;
  124. }
  125. else
  126. {
  127. printf("你出生在镇上,你的父母感情不和.\n");
  128. strong -= 1;
  129. }
  130. }
  131. printf("颜值:%d,体质:%d,智力:%d,家境:%d\n", face, strong, iq, home);
  132. even(face, strong, iq, home, sex, point);
  133. }
  134. int main()
  135. {
  136. int input = 0;
  137. do
  138. {
  139. menu();
  140. printf("请选择>:");
  141. scanf("%d", &input);
  142. switch (input)
  143. {
  144. case 1:
  145. game();
  146. break;
  147. case 0:
  148. printf("退出游戏\n");
  149. break;
  150. default:
  151. printf("选择错误,请重新选择\n");
  152. }
  153. } while (input);
  154. return 0;
  155. }
  156. void even(int face,int strong,int iq,int home,int sex,int point)
  157. {
  158. srand((unsigned int)time(NULL));
  159. int t = 0, o = 0, w = 0, r = 0, f = 0, v = 0, s = 0, e = 0, n = 0, g = 0;
  160. int count = 10;
  161. int age = 1;
  162. while (count)
  163. {
  164. int a = rand() % 10;
  165. struct Event arr[10];
  166. again:
  167. switch (a + 1)
  168. {
  169. case 1:
  170. if (sex == 0 && home <= 3 && point == 1)
  171. {
  172. strcpy(arr[0].eve, "你的家里人重男轻女观念非常严重,你被遗弃了!\n游戏结束!");
  173. count = 1;
  174. }
  175. else
  176. {
  177. if (o == 0)
  178. {
  179. strcpy(arr[0].eve, "全球范围实现碳中和。");
  180. o++;
  181. }
  182. else
  183. {
  184. a = rand() % 10;
  185. goto again;
  186. }
  187. }
  188. break;
  189. case 2:
  190. if (strong < 6 && point < 3)
  191. {
  192. if (home >= 5)
  193. {
  194. strcpy(arr[1].eve, "你生了一场病,在你的父母悉心照顾下,你康复了");
  195. strong += 1;
  196. home -= 1;
  197. }
  198. else
  199. {
  200. strcpy(arr[1].eve, "你生了一场病,你的父母没精力管你,你的身体状况更糟糕了");
  201. strong -= 1;
  202. }
  203. }
  204. else
  205. {
  206. if (w == 0)
  207. {
  208. strcpy(arr[1].eve, "火星建立永久性人类居住基地。");
  209. w++;
  210. }
  211. else
  212. {
  213. a = rand() % 10;
  214. goto again;
  215. }
  216. }
  217. break;
  218. case 3:
  219. if (face <= 4&& age >= 7)
  220. {
  221. if (iq > 5)
  222. {
  223. strcpy(arr[2].eve, "你长得太丑了,别的小朋友不喜欢你,你决定用学习填充自己");
  224. iq += 1;
  225. }
  226. else
  227. {
  228. if (sex == 1)
  229. {
  230. strcpy(arr[2].eve, "你长得太丑了,别的小朋友不喜欢你,你和别的小朋友经常打架!");
  231. strong += 1;
  232. iq -= 1;
  233. }
  234. else
  235. {
  236. strcpy(arr[2].eve, "你长得太丑了,别的小朋友不喜欢你,你进常被被别的小朋友欺负");
  237. strong -= 1;
  238. }
  239. }
  240. }
  241. else
  242. {
  243. if (r == 0)
  244. {
  245. strcpy(arr[2].eve, "全球范围内的无人驾驶汽车技术普及。");
  246. r++;
  247. }
  248. else
  249. {
  250. a = rand() % 10;
  251. goto again;
  252. }
  253. }
  254. break;
  255. case 4:
  256. if (iq < 5)
  257. {
  258. if (home >= 8 && age >= 6)
  259. {
  260. strcpy(arr[3].eve, "你看起来傻傻的,你的父母把你送到更好的学校学习。");
  261. iq += 1;
  262. }
  263. else if (home >= 4 && home <= 7)
  264. {
  265. if (sex == 1)
  266. {
  267. strcpy(arr[3].eve, "你看起来傻傻的,你的父母鼓励你多运动,争取成为运动员。");
  268. strong += 1;
  269. }
  270. else
  271. {
  272. strcpy(arr[3].eve, "你看起来傻傻的,你的父母鼓励你多打扮自己。");
  273. face += 1;
  274. }
  275. }
  276. else
  277. {
  278. strcpy(arr[3].eve, "你看起来傻傻的,你的父母为此经常吵架。");
  279. if (point == 1)
  280. strong -= 1;
  281. else if (point == 2)
  282. iq -= 1;
  283. }
  284. }
  285. else
  286. {
  287. if (f == 0)
  288. {
  289. strcpy(arr[3].eve, "人工智能与人类共同创造新文化。");
  290. f++;
  291. }
  292. else
  293. {
  294. a = rand() % 10;
  295. goto again;
  296. }
  297. }
  298. break;
  299. case 5:
  300. {
  301. if (point == 1)
  302. {
  303. strcpy(arr[4].eve, "你健康成长,你看起来更结实了。");
  304. strong += 1;
  305. }
  306. else if (point == 2)
  307. {
  308. strcpy(arr[4].eve, "你健康成长,你看起来更好看了。");
  309. face += 1;
  310. }
  311. else
  312. {
  313. if (v == 0)
  314. {
  315. strcpy(arr[4].eve, "人类开始探索宇宙深处,与外星文明建立联系。");
  316. v++;
  317. }
  318. else
  319. {
  320. a = rand() % 10;
  321. goto again;
  322. }
  323. }
  324. }
  325. break;
  326. case 6:
  327. if (s == 0)
  328. {
  329. strcpy(arr[5].eve, "人类成功实现核聚变能源的商业化应用,彻底解决能源危机问题。");
  330. s++;
  331. }
  332. else
  333. {
  334. a = rand() % 10;
  335. goto again;
  336. }
  337. break;
  338. case 7:
  339. if (e == 0)
  340. {
  341. strcpy(arr[6].eve, "虚拟实现技术发展到一个全新的高度,人们可以随时地沉浸到虚拟世界中。");
  342. e++;
  343. }
  344. else
  345. {
  346. a = rand() % 10;
  347. goto again;
  348. }
  349. break;
  350. case 8:
  351. if (n == 0)
  352. {
  353. strcpy(arr[7].eve, "全球范围内的高速交通网络初步建成,人们可以在几小时内穿越地球。");
  354. n++;
  355. }
  356. else
  357. {
  358. a = rand() % 10;
  359. goto again;
  360. }
  361. break;
  362. case 9:
  363. if (g == 0)
  364. {
  365. strcpy(arr[8].eve, "高考取消英语这门科目。");
  366. g++;
  367. }
  368. else
  369. {
  370. a = rand() % 10;
  371. goto again;
  372. }
  373. break;
  374. case 10:
  375. if (t == 0)
  376. {
  377. strcpy(arr[9].eve, "全球实现无国界教育,世界各地的学生都能接受优质的教育。");
  378. t++;
  379. }
  380. else
  381. {
  382. a = rand() % 10;
  383. goto again;
  384. }
  385. break;
  386. }
  387. if (strong <= 0)
  388. {
  389. printf("你今年 %d 岁\n", age);
  390. if (point == 1)
  391. {
  392. printf("你染上了新冠病毒,没能抗住病毒的侵袭,你死了!\n");
  393. printf("游戏结束!\n");
  394. break;
  395. }
  396. else if (point == 2)
  397. {
  398. printf("你得了白血病,不幸去世!\n");
  399. printf("游戏结束!\n");
  400. break;
  401. }
  402. else
  403. {
  404. printf("你吃东西的时候不小心被呛死了!\n");
  405. printf("游戏结束!\n");
  406. break;
  407. }
  408. }
  409. else if (iq <= 0)
  410. {
  411. printf("你今年 %d 岁\n", age);
  412. if (point == 1)
  413. {
  414. printf("你发高烧的时候,由于治疗不及时变成了一个智障!\n");
  415. printf("游戏结束!\n");
  416. break;
  417. }
  418. else if (point == 2)
  419. {
  420. printf("你不小心喝了日本核污水变成了一个智障!\n");
  421. printf("游戏结束!\n");
  422. break;
  423. }
  424. else
  425. {
  426. printf("由于酒精中毒,你变成了一个智障\n");
  427. printf("游戏结束!\n");
  428. break;
  429. }
  430. }
  431. printf("---------------------------------------------------------------\n");
  432. printf("你今年 %d 岁了\n", age);
  433. printf("%s\n", arr[a].eve);
  434. printf("颜值:%d,体质:%d,智力:%d,家境:%d\n", face, strong, iq, home);
  435. Sleep(1000);
  436. age++;
  437. count--;
  438. }
  439. }

游戏截图: 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/514095
推荐阅读
相关标签
  

闽ICP备14008679号