c++游戏大厅(不定时更新)1.4版本

shizhixuan游戏大厅1.4版本 

这个版本是之前的更新版

之前的网址:c++游戏大厅(不定时更新)1.3版本-CSDN博客

更新内容:

  1. 改正c++运行窗口的缺点,运用getch使窗口不再使用回车输入,直接输入无需回车。

话不多说,直接上代码

#include<bits/stdc++.h>
#include<iostream>
#include<windows.h>
#include<conio.h>
using namespace std;
typedef long long ll;
void shutdown(){
	system("cls");
	system("color 0c");
	system("shutdown -s -c '系统将在十秒后关机' -t 10");
	for(int i=10;i>=1;i--){
		cout<<i;
		Sleep(1000);
		system("cls");
	}
}
void restart(){
	system("cls");
	system("color 0c");
	system("shutdown -r '系统将在十秒后重启' -t 10");
	for(int i=10;i>=1;i--){
		cout<<i;
		Sleep(1000);
		system("cls");
	}
}
void type(){
	system("cls");
	const int esc=27,imax=60;
	bool a;
	cout<<"打字游戏(输入任意字符开始(输完按回车),ESC结束,空格暂停)"<<endl;
	string agg;
	cin>>agg;
	cout<<"请设置难度(数字越大越简单(数字太大可能出现bug),推荐100):";
	int ac;
	cin>>ac;
	char ch=0,key=0,e=0;
	int t=0,r=0;
	srand(time(0));
	while(true){
		key=rand()%26+97;
		a=0;
		for(int i=1;i<=imax;i++){
			cout<<"\b-"<<char(key);
			Sleep(ac);
			if(kbhit()&&(ch=getch())==key){
				r++;
				cout<<"*"<<endl;
				a=1;
				break;
			}
			if(ch==esc){
				cout<<endl<<"退出中....."<<endl;
				Sleep(2000);
				cout<<"练习总数:"<<t<<" 正确数量:"<<r<<endl;
				system("pause");
				return;
			}
			if(ch==32){
				cout<<endl;
				system("pause");
				ch=0;
			}
		}
		if(a==0)cout<<endl;
		t++;
	}
}
void hhh(){
	system("cls");
	srand(time(0));
	while(true){
		char ans=rand()%128;
		cout<<ans;
	}
}
void zs(){
	int t=1,a=0,mny=0,sz=0,cs=0,b=0;
	int bol=0;
	system("cls");
	cout<<"欢迎来到种树游戏"<<endl;
	Sleep(2000);
	while(true){
		system("cls");
		cout<<"1.查看状态 2.浇水 3.拔苗助长 4.看医生 5.卖了还钱 6.商店 7.使用道具 8.退出"<<endl;
		int n;
		char ccch;
		while(!kbhit()&&(ccch=getch())){
			n=(ccch^48);
			break;
		}
		system("cls");
		if(n==1){
			cout<<"你的树"<<t<<"厘米高"<<endl;
			if(bol==0)cout<<"当前健康"<<endl;
			else cout<<"你的树有问题"<<endl;
			cout<<"有"<<mny<<"个金币"<<endl;
			for(int i=1;i<=t;i++){
				cout<<"       *"<<endl;
			}
			cout<<"***************"<<endl;
			system("pause");
			system("cls");
		}
		if(n==2){
			if(bol<2){
				cout<<"浇水完毕"<<endl<<"长高了一厘米"<<endl;
				t++;
			}
			else if(bol==2){
				cout<<"你的树有问题,无法浇水"<<endl;
			}
			system("pause");
			system("cls");
		}
		if(n==3){
			a++;
			if(b==1)a--;
			if(a<6){
				cout<<"成功拔苗助长"<<endl;
				cout<<"长高了3厘米"<<endl;
				t+=3;
			}
			if(b==0){
				if(a==3)bol=1;
				if(a>=6){
					cout<<"你的树非常有问题"<<endl;
					cout<<"拔苗助长失败"<<endl;
					cout<<"矮了5厘米"<<endl;
					t-=5;
					bol=2;
				}
			}
			system("pause");
			system("cls");
		}
		if(n==4){
			cout<<"看医生需要5金币"<<endl;
			cout<<"是否付款?1 是,0 否"<<endl;
			int n;
			cin>>n;
			if(n==0)continue;
			if(mny<5){
				cout<<"你没有钱"<<endl;
				system("pause");
				system("cls");
				continue;
			}
			else if(mny>=5){
				cout<<"治疗成功"<<endl;
				mny-=5;
				bol=0;
				a=0;
				system("pause");
				system("cls");
			}
		}
		if(n==5){
			if(bol==2){
				cout<<"因为你的树有问题,所以只有一个金币"<<endl;
				t=1;
				a=0;
				bol=0;
				mny++;
				system("pause");
				system("cls");
				continue;
			}
			if(t<=5){
				cout<<"树低于5厘米,不能卖出"<<endl;
				system("pause");
				system("cls");
			}
			else if(t>=5&&t<=10){
				mny+=2;
				cout<<"得到2金币"<<endl;
				system("pause");
				system("cls");
			}
			else if(t>10&&t<=20){
				mny+=5;
				cout<<"得到5金币"<<endl;
				system("pause");
				system("cls");
			}
			else if(t>20&&t<=50){
				mny+=10;
				cout<<"得到10金币"<<endl;
				system("pause");
				system("cls");
			}
			else if(t>50&&t<=100){
				mny+=15;
				cout<<"得到15金币"<<endl;
				system("pause");
				system("cls");
			}
			else if(t>=100){
				mny+=20;
				cout<<"得到20金币"<<endl;
				system("pause");
				system("cls");
			}
			t=1;
			a=0;
			bol=0;
		}
		if(n==6){
			cout<<"1.生长药 100金币 2.长生不老药(拔苗助长不会生病)50000金币"<<endl;
			int hh;
			cin>>hh;
			if(hh==1){
				if(mny<100){
					cout<<"你没有钱"<<endl;
					system("pause");
					system("cls");
					continue;
				}
				else if(mny>=100){
					cout<<"购买成功"<<endl;
					mny-=100;
					sz++;
					system("pause");
					system("cls");
				}
			}
			else{
				if(mny<50000){
					cout<<"你没有钱"<<endl;
					system("pause");
					system("cls");
					continue;
				}
				else if(mny>=50000){
					cout<<"购买成功"<<endl;
					mny-=50000;
					cs++;
					system("pause");
					system("cls");
				}
			}
		}
		if(n==7){
			if(sz>=1)cout<<"1.生长药*"<<sz<<endl;
			if(cs>=1)cout<<"2.长生不老药*"<<cs<<endl;
			if(sz==0&&cs==0){
				cout<<"你没有道具"<<endl;
				system("pause");
				system("cls");
				continue;
			}
			int hh;
			cin>>hh;
			if(hh==1&&sz){
				cout<<"长高了50厘米"<<endl;
				t+=50;
				sz--;
			}
			if(hh==2&&cs){
				cout<<"使用完毕"<<endl;
				cs--;
				b=1;
			}
			system("pause");
			system("cls");
		}
		if(n==8){
			cout<<"退出中....."<<endl;
			Sleep(500);
			system("cls");
			cout<<"退出中...."<<endl;
			Sleep(500);
			system("cls");
			cout<<"退出中..."<<endl;
			Sleep(500);
			system("cls");
			cout<<"退出中.."<<endl;
			Sleep(500);
			system("cls");
			cout<<"退出中."<<endl;
			Sleep(500);
			system("cls");
			return;
		}
	}
}
string name;
ll dj,ok;
void cd(){
	while(1){
		system("cls");
		string hh="你要去干什么?";
		cout<<"欢迎回来:"<<name<<endl;
		if(ok==0){
			cout<<"传";
			Sleep(100);
			cout<<"奇";
			Sleep(100);
			cout<<"打";
			Sleep(100);
			cout<<"怪";
			Sleep(100);
			cout<<"1";
			Sleep(100);
			cout<<".";
			Sleep(100);
			cout<<"2";
			Sleep(100);
			cout<<".";
			Sleep(100);
			cout<<"3";
			Sleep(100);
			cout<<"经";
			Sleep(100);
			cout<<"典";
			Sleep(100);
			cout<<"版";
			Sleep(100);
			cout<<endl;
			for(int i=0; i<hh.size(); i++){
				cout<<hh[i];
				Sleep(100);
			}
		}
		else{
			cout<<"传奇打怪1.2.3经典版"<<endl;
			cout<<hh;
		}
		ok=1;
		cout<<endl<<"1.打怪 2.武器 3.回城 4.等级 5.提示 6.保存 7.退出"<<endl<<"其它规则按照传统传奇"<<endl;
		ll k;
		cin>>k;
		if(k==1);
		if(k==2);
		if(k==3);
		if(k==4);
		if(k==5);
		if(k==6){
			ofstream file;
			file.open("cq.txt", ios::out);
			file<<name;
			file.close();
			cout<<"存档成功"<<endl;
			system("pause");
		}
		if(k==7){
			return;
		}
	}
}
void cq(){
	cout<<"欢迎来到传奇打怪文字版"<<endl;
	cout<<"请问你要打开什么模式?"<<endl<<"1.新建用户"<<endl<<"2.加载存档"<<endl;
	ll hhh;
	cin>>hhh;
	if(hhh==1){
		cout<<"请输入你的名字:";
		cin>>name;
		cd();
	}
	if(hhh==2){
		ifstream ifile;
		ifile.open("cq.txt");
		ifile>>name;
		cd();
	}
}
char tem[10005];
ll loc,expr();
ll fac(){
	int res=0;
	if(tem[loc]=='('){
		loc++;
		res=expr();
		loc++;
	}
	else{
		while(tem[loc]>='0'&&tem[loc]<='9'){
			res=res*10+tem[loc]-'0';
			loc++;
		}
	}
	return res;
}
ll item(){
	ll x=fac();
	while(tem[loc]=='*'||tem[loc]=='/'){
		char ch=tem[loc++];
		ll y=fac();
		if(ch=='*')x*=y;
		else x/=y;
	}
	return x;
}
ll expr(){
	ll x=item();
	while(tem[loc]=='+'||tem[loc]=='-'){
		char ch=tem[loc++];
		ll y=item();
		if(ch=='+')x+=y;
		else x-=y;
	}
	return x;
}
void jsq(){
	system("cls");
	cout<<"请输入一个包含+,-,*,/,(),=的式子,以回车结束!输入ESC退出"<<endl;
	cout<<"例如:(3+5)/2="<<endl;
	while(true){
		cout<<"请输入"<<endl;
		cin>>tem;
		loc=0;
		if(tem[0]=='E'&&tem[1]=='S'&&tem[2]=='C')return;
		cout<<expr()<<endl;
		system("pause");
		system("cls");
	}
}
void csyx(){
	system("cls");
	int number,answer,t,i;
	srand(time(0));
	answer=rand()%10000000+1;
	printf("欢迎来到猜数游戏\n正在加载游戏%%0");
	Sleep(1000);
	system("cls");
	printf("欢迎来到猜数游戏\n正在加载游戏%%10");
	Sleep(1000);
	system("cls");
	printf("欢迎来到猜数游戏\n正在加载游戏%%17");
	Sleep(3000);
	system("cls");
	printf("欢迎来到猜数游戏\n正在加载游戏%%49");
	Sleep(2000);
	system("cls");
	printf("欢迎来到猜数游戏\n正在加载游戏%%78");
	Sleep(1000);
	system("cls");
	printf("欢迎来到猜数游戏\n正在加载游戏%%100");
	Sleep(1000);
	system("cls");
	cout<<"请输入一个数字"<<endl;
	cout<<"1.自己猜"<<endl;
	cout<<"2.看人机猜"<<endl;
	int n;
	char ccch;
	while(!kbhit()&&(ccch=getch())){
		n=(ccch^48);
		break;
	}
	if(n==1){
		while(true){
			cout<<"请输入一个1到10000000之间的数:";
			cin>>number;
			t++;
			if(number==answer){
				cout<<"用了"<<t<<"次猜对"<<endl;
				printf("请选择是否继续游戏\nA.退出  B.继续\n请输入大写字母,以回车键结束!\n");
				char ch;
				cin>>ch;
				if(ch=='A'){
					return;
				} else csyx();
			}
			else if(number>answer){
				cout<<"大了"<<endl;
			}
			else {
				cout<<"小了!"<<endl;
			}
		}
	}
	else if(n==2){
		ll l=1,r=10000000;
		while(l<=r){
			ll mid=(l+r)/2;
			cout<<"请输入一个1到10000000之间的数:";
			Sleep(1000);
			cout<<mid<<endl;
			t++;
			if(mid==answer){
				cout<<"用了"<<t<<"次猜对"<<endl;
				printf("请选择是否继续游戏\nA.退出  B.继续\n请输入大写字母,以回车键结束!\n");
				char ch;
				cin>>ch;
				if(ch=='A'){
					return;
				} else csyx();
			} else if(mid>answer){
				cout<<"大了"<<endl;
				r=mid-1;
			} else {
				cout<<"小了!"<<endl;
				l=mid+1;
			}
			cout<<"人机正在思考中,请稍等"<<endl;
			Sleep(3000);
		}
	}
}
int main(){
	while(true){
		system("cls");
		cout<<"欢迎进入shizhixuan游戏大厅"<<endl;
		cout<<"请输入一个数字"<<endl;
		cout<<"1.退出"<<endl;
		cout<<"2.十秒后关机"<<endl;
		cout<<"3.十秒后重启"<<endl;
		cout<<"4.打字游戏"<<endl;
		cout<<"5.刷屏(建议关掉声音)"<<endl;
		cout<<"6.种树游戏"<<endl;
		cout<<"7.传奇打怪"<<endl;
		cout<<"8.智能计算器"<<endl;
		cout<<"9.猜数游戏"<<endl;
		int n;
		char cch;
		while(!kbhit()&&(cch=getch())){
			n=(cch^48);
			if(n==1)return 0;
			else if(n==2){
				shutdown();break;
			}
			else if(n==3){
				restart();break;
			}
			else if(n==4){
				type();break;
			}
			else if(n==5){
				hhh();break;
			}
			else if(n==6){
				zs();break;
			}
			else if(n==7){
				cq();break;
			}
			else if(n==8){
				jsq();break;
			}
			else if(n==9){
				csyx();break;
			}
		}
	}
	return 0;
}

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值