#include <bits/stdc++.h>
using namespace std;
void Start();
void GetResults();
int i, j, life, maxrand;
char c;
void Start()
{
i = 0;
j = 0;
life = 0;
maxrand = 6;
cout << "选一个等级:\n"; // the user has to select a difficutly level
cout << "1 : 简单 (0-20)\n";
cout << "2 : 中等 (0-40)\n";
cout << "3 : 困难 (0-60)\n";
cout << "来选一个吧!!!\n";
c = 30;
cin >> c; // read the user's choice
cout << "\n";
switch (c)
{
case '1':
maxrand = 20; // the random number will be between 0 and maxrand
break;
case '2':
maxrand = 40;
break;
case '3':
maxrand = 60;
break;
default:
exit(0);
break;
}
life = 5; // number of lifes of the player
srand((unsigned)time(NULL)); /
C++实现猜数游戏(源代码)
最新推荐文章于 2024-07-24 07:52:23 发布
本文介绍了一款使用C++编写的猜数游戏。通过详细讲解源代码,帮助读者理解C++的基本语法和流程控制。游戏规则简单,计算机随机生成一个介于1到100之间的数字,玩家尝试猜测,程序会给出提示,直到猜中为止。
摘要由CSDN通过智能技术生成