猜数游戏(加载和特效不是原创)

Hello!大家好,我一直对rand函数别有钟爱,所以我编了一个猜~数~游~戏

上~~~码!

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<windows.h>
#include<bits/stdc++.h>
using namespace std;
int cnt=0;
void texiao(){
	for(int i=1; i<=10; i++)
	{
		system("color 2f");
		Sleep(10);
		system("color 0f");
		Sleep(10);
	}
	system("color f2");
}
void jiazai(){
	printf("正在检查网络...\n0");
	Sleep(150);
	system("cls");
	printf("正在连接服务器...\n▊15");
	Sleep(210);
	system("cls");
	printf("加载资源中...\n█▎25");
	Sleep(180);
	system("cls");
	printf("加载资源中...\n██▊55");
	Sleep(120);
	system("cls");
	printf("加载资源中...\n███▌70");
	Sleep(90);
	system("cls");
	printf("加载资源中...\n███▊75");
	Sleep(450);
	system("cls");
	printf("正在加载随机数\n████▌90");
	Sleep(120);
	system("cls");
	printf("正在加载控制台\n█████100");
	Sleep(300);
	system("cls");
	printf("正在进入猜数界面...\n█████100");
	Sleep(900);
	system("cls"); 
}
void dazi(string s){
	for(int i=0;i<s.size();i++){
		//TODO
		cout<<s[i];
		Sleep(15);
	}
}
int main(){
	//猜数游戏(自制)
	while(1){
		int b;
		system("color f2");
		CONSOLE_CURSOR_INFO cursor_info = { 1,0 };
		SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
		system("mode con cols=100 lines=20&&title QAQ猜数游戏QAQ");
		system("color f2");
		cout<<"                                  ";
		string s="QAQ猜数游戏QAQ";
		dazi(s);
		texiao();
		system("cls");
		cout<<"\n";
		s="请选择难度:";
		cout<<"                                  ";
		dazi(s);
		cout<<"\n";
		cout<<"               ";
		s="1.数字范围:1~15 难度★";
		dazi(s);
		cout<<"\n";
		cout<<"               ";
		s="2.数字范围:1~30 难度★★★";
		dazi(s);
		cout<<"\n";
		cout<<"               ";
		s="3.数字范围:1~50 难度★★★★★";
		dazi(s);
		cout<<"\n";
		cout<<"               ";
		s="4.数字范围:1~75 难度:王者";
		dazi(s);
		cout<<"\n";
		cout<<"               ";
		s="5.数字范围:1~100 难度:半神";
		dazi(s);
		cout<<"\n";
		cout<<"               ";
		s="6.数字范围:1~130 难度:神";
		dazi(s);
		cout<<"\n";
		cout<<"               ";
		s="7.数字范围:1~150 难度:超神";
		dazi(s);
		cout<<"\n";
		cout<<"               ";
		s="8.退出";
		dazi(s);
		cout<<"\n";
		cout<<"               ";
		s="请选择:(输入序号)";
		dazi(s);
		int a,v;
		cin>>a;
		if(a==1){
			jiazai();
			srand(time(0));     
			v=rand()%15;
			system("cls");
			cout<<"                                  ";
			s="您有五次机会";
			dazi(s);
			cout<<"\n";
			cout<<"                                  ";
			s="请输入:(1~15)";
			dazi(s);
			cout<<"\n";
			while(cin>>b&&b!=v){
				//TODO
				if(cnt==4&&b!=v){
					cout<<"                                  抱歉,您失败了!";
					Sleep(1000);
					cnt=0;
					break;
				}	
				if(b>v)	cout<<"                                  大了!";
				if(b<v){
					//TODO
					cout<<"                                  小了!";
				}
				cnt++;
			}
			cout<<"                                  恭喜猜中!";
			texiao();
		}
		if(a==2){
			jiazai();
			srand(time(0));     
			v=rand()%30;
			system("cls");
			cout<<"                                  ";
			s="您有五次机会";
			dazi(s);
			cout<<"\n";
			cout<<"                                  ";
			s="请输入:(1~30)";
			dazi(s);
			cout<<"\n";
			while(cin>>b&&b!=v){
				//TODO
				if(cnt==4&&b!=v){
					cout<<"                                  抱歉,您失败了!";
					Sleep(1000);
					cnt=0;
					break;
				}	
				if(b>v)	cout<<"                                  大了!";
				if(b<v){
					//TODO
					cout<<"                                  小了!";
				}
				cnt++;
			}
			cout<<"                                  恭喜猜中!";
			texiao();
		}
		if(a==3){
			jiazai();
			srand(time(0));     
			v=rand()%50;
			system("cls");
			cout<<"                                  ";
			s="您有六次机会";
			dazi(s);
			cout<<"\n";
			cout<<"                                  ";
			s="请输入:(1~50)";
			dazi(s);
			cout<<"\n";
			while(cin>>b&&b!=v){
				//TODO
				if(cnt==5&&b!=v){
					cout<<"                                  抱歉,您失败了!";
					Sleep(1000);
					cnt=0;
					break;
				}	
				if(b>v)	cout<<"                                  大了!";
				if(b<v){
					//TODO
					cout<<"                                  小了!";
				}
				cnt++;
			}
			cout<<"                                  恭喜猜中!";
			texiao();
		}
		if(a==4){
			jiazai();
			srand(time(0));     
			v=rand()%75;
			system("cls");
			cout<<"                                  ";
			s="您有六次机会";
			dazi(s);
			cout<<"\n";
			cout<<"                                  ";
			s="请输入:(1~75)";
			dazi(s);
			cout<<"\n";
			while(cin>>b&&b!=v){
				//TODO
				if(cnt==5&&b!=v){
					cout<<"                                  抱歉,您失败了!";
					Sleep(1000);
					cnt=0;
					break;
				}	
				if(b>v)	cout<<"                                  大了!";
				if(b<v){
					//TODO
					cout<<"                                  小了!";
				}
				cnt++;
			}
			cout<<"                                  恭喜猜中!";
			texiao();
		}
		if(a==5){
			jiazai();
			srand(time(0));     
			v=rand()%100;
			system("cls");
			cout<<"                                  ";
			s="您有七次机会";
			dazi(s);
			cout<<"\n";
			cout<<"                                  ";
			s="请输入:(1~100)";
			dazi(s);
			cout<<"\n";
			while(cin>>b&&b!=v){
				//TODO
				if(cnt==6&&b!=v){
					cout<<"                                  抱歉,您失败了!";
					Sleep(1000);
					cnt=0;
					break;
				}	
				if(b>v)	cout<<"                                  大了!";
				if(b<v){
					//TODO
					cout<<"                                  小了!";
				}
				cnt++;
			}
			cout<<"                                  恭喜猜中!";
			texiao();
		}
		if(a==6){
			jiazai();
			srand(time(0));     
			v=rand()%130;
			system("cls");
			cout<<"                                  ";
			s="您有八次机会";
			dazi(s);
			cout<<"\n";
			cout<<"                                  ";
			s="请输入:(1~130)";
			dazi(s);
			cout<<"\n";
			while(cin>>b&&b!=v){
				//TODO
				if(cnt==7&&b!=v){
					cout<<"                                  抱歉,您失败了!";
					Sleep(1000);
					cnt=0;
					break;
				}	
				if(b>v)	cout<<"                                  大了!";
				if(b<v){
					//TODO
					cout<<"                                  小了!";
				}
				cnt++;
			}
			cout<<"                                  恭喜猜中!";
			texiao();
		}
		if(a==7){
			jiazai();
			srand(time(0));     
			v=rand()%150;
			system("cls");
			cout<<"                                  ";
			s="您有八次机会";
			dazi(s);
			cout<<"\n";
			cout<<"                                  ";
			s="请输入:(1~150)";
			dazi(s);
			cout<<"\n";
			while(cin>>b&&b!=v){
				//TODO
				if(cnt==7&&b!=v){
					cout<<"                                  抱歉,您失败了!";
					Sleep(1000);
					cnt=0;
					break;
				}	
				if(b>v)	cout<<"                                  大了!";
				if(b<v){
					//TODO
					cout<<"                                  小了!";
				}
				cnt++;
			}
			cout<<"                                  恭喜猜中!";
			texiao();
		}
		if(a==8){
			cout<<"退出中";
			for(int i=0;i<=5;i++){
				//TODO
				cout<<".";
				Sleep(300);
			}
			cout<<"按任意键退出";
			return 0;
			
		}
		system("cls");
	}
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值