栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

DEV c++自带的猜数游戏

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

DEV c++自带的猜数游戏

#include 
#include 
#include 

using namespace std;
	
void Start();
void GetResults();

int i, j, life, maxrand,n,h,d;
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-15)n";
	cout << "2 : 中等 (0-30)n";
	cout << "3 : 困难 (0-50)n";
	cout << "4 : 地狱 (0-100)n";
	cout << "5 : 自虐 (0-10000)n"; 
	cout << "选择一个难度"<> c;                   // read the user's choice
	cout << "n";
	 
	switch (c) {
		case '1':
			maxrand = 15;  // the random number will be between 0 and maxrand
			break;
		case '2':
			maxrand = 30;
			break;
		case '3':
			maxrand = 50;
			break;
		case '4':
			maxrand = 100;
			break;
		case '5':
			maxrand = 10000;
			break;
		default:
			exit(0);
		break;
	}
	life = 5;         // number of lifes of the player
	srand((unsigned)time(NULL)); // init Rand() function
	j = rand() % maxrand;  // j get a random value between 0 and maxrand
	if(maxrand>=1)cout<<"开挂要输入密码。密码是:"<>n;
	if(n!=123654) cout<<"密码错误!"<>h;
    if(h!=12365412)cout<<"密码错了,很遗憾!你不能开外挂,你不是卢本伟!"<> i;
	if((i>maxrand) || (i<0)) { // if the user number isn't correct, restart
		cout << "计算错误!!! n" << maxrand;
		GetResults();
	}
	if(i == j) {
		cout << "你赢了!nn"; // the user found the secret number
		Start();
	} else if(i>j) {
		cout << "太大了n";
		life = life - 1;
		cout << "你的次数: " << life << "nn";
		GetResults();
	} else if(i 

代码如上

用DEV c++打的

有外挂

运行时的外挂密码(对应第一个和第二个)1,123654    2,12365412

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/330112.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号