https://blog.csdn.net/shizhixuan1314/article/details/131673893?spm=1001.2014.3001.5501
shizhixuan游戏大厅1.2版本
这个版本是之前的更新版
之前的网址:https://blog.csdn.net/shizhixuan1314/article/details/130446195?spm=1001.2014.3001.5502h
话不多说,直接上代码(传奇打怪无法打开 )
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
typedef long long ll;
void shutdown(){
system("cls");
system("color 0c");
system("shutdown -s -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;
cin>>n;
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;
system("pause");
system("cls");
}
}
}
if(n==7){
if(sz>=1)cout<<"1.生长药*"<<sz<<endl;
if(cs>=1)cout<<"2.长生不老药*"<<cs<<endl;
else{
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;
}
}
}
void cq(){
system("cls");
const int esc=27;
cout<<"欢迎来到热血传奇!"<<endl;
cout<<"请创建用户"<<endl;
cout<<"请输入用户名:";
string s;
cin>>s;
system("cls");
cout<<s<<",正在转载游戏中";
for(int i=1;i<=10;i++){
cout<<".";
Sleep(500);
}
system("cls");
cout<<"游戏规则:"<<endl;
cout<<"WASD移动人物"<<endl;
cout<<"选择地图请输入数字"<<endl;
cout<<"ESC退出游戏"<<endl;
cout<<"打怪过程中想使用回城石请按 " <<"=(回城石无限)"<<endl;
system("pause");
while(true){
system("cls");
cout<<"当前在安全区"<<endl;
cout<<"请选择地图,以回车结束!"<<endl;
cout<<"1.新手 2.青铜 3.白银 4.黄金 5.钻石 6.王者"<<endl;
int d;
scanf("%d",&d);
if(kbhit()&&getch()==esc){
system("cls");
cout<<"结束?1 是,0 否"<<endl;
bool temp;
cin>>temp;
if(temp==1)return;
else{
system("cls");
cout<<"继续游戏";
Sleep(2000);
}
}
if(d==1){
system("cls");
/*
if(kbhit()&&getch()=='='){
system("cls");
continue;
}
if(kbhit()&&getch()==esc){
system("cls");
cout<<"结束?1 是,0 否"<<endl;
bool temp;
cin>>temp;
if(temp==1)return;
else{
system("cls");
cout<<"继续游戏";
Sleep(2000);
}
}
*/
cout<<"欢迎来到新手地图,";
cout<<"按x键查看状态,确认游戏规则后请按回车开始游戏"<<endl;
system("pause");
system("cls");
while(true){
if(kbhit()&&getch()==esc){
system("cls");
cout<<"结束?1 是,0 否"<<endl;
bool temp;
cin>>temp;
if(temp==1)return;
else{
system("cls");
cout<<"继续游戏";
Sleep(2000);
system("cls");
}
}
if(kbhit()&&getch()=='='){
system("cls");
break;
}
}
}
}
}
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");
}
}
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;
int n;
cin>>n;
if(n==1)break;
else if(n==2)shutdown();
else if(n==3)restart();
else if(n==4)type();
else if(n==5)hhh();
else if(n==6)zs();
else if(n==7)cq();
else if(n==8)jsq();
}
return 0;
}