漏洞百出的代码
#include<bits/stdc++.h>
#include<windows.h>
#define random(a,b) (rand()%(b-a)+a)
using namespace std;
int sm=100,gj=20,mf=20,jb=100,in,sj;
void exit(int value);
void game();
void slc(){
cout<<"你来到了试炼场";
system("cls");
cout<<"试炼场分为1.初级玄兽 2.中级玄兽 3.高级玄兽 4.玄灵兽 5.返回"<<endl<<"你要进入哪里?";
cin>>in;
if(in==1){
int xsm=80;
while(xsm>1){
int xgj=40;
cout<<"是否攻击 1.Yes 2.No";
cin>>in;
if(in==1){
xsm-=gj;
xgj=10;
}
system("cls");
cout<<"-"<<xgj;
sm-=xgj;
if(sm<=0){
cout<<"你死了";
exit(0);
}
}
srand((int)time(0));
cout<<"你赢了!血量++攻击力++金币++";
sm+=random(1,20);
gj+=random(1,5);
jb+=random(10,20);
system("cls");
slc();
}
if(in==2){
srand((int)time(0));
int xsm=160;
while(xsm>1){
srand((int)time(0));
sj=random(1,20);
if(sj==5){
xsm+=60;
cout<<"玄兽回血中……";
}
int xgj=40;
cout<<"是否攻击 1.Yes 2.No";
cin>>in;
if(in==1){
xsm-=gj;
xgj=20;
}
system("cls");
cout<<"-"<<xgj;
sm-=xgj;
if(sm<=0){
cout<<"你死了";
exit(0);
}
}
cout<<"你赢了!血量++攻击力++金币++魔法++";
sm+=random(10,25);
gj+=random(1,10);
jb+=random(15,30);
mf+=random(1,20);
system("cls");
slc();
}
if(in==3){
cout<<"暂时未开放" ;
system("cls");
slc();
}
if(in==4){
cout<<"暂时未开放" ;
system("cls");
slc();
}
if(in==5){
game();
}
}
void slwb(){
cout<<"暂时未开放" ;
system("cls");
game();
}
void slnb(){
cout<<"暂时未开放" ;
system("cls");
game();
}
void hs(){
cout<<"暂时未开放" ;
system("cls");
game();
}
void bc(){
cout<<"暂时未开放" ;
system("cls");
game();
}
void js(){
system("cls");
cout<<"你来到了集市,这里有1.百草果(生命+=50,5元) 2.玄丹(生命-=10 攻击力+=500 500元) 3.灵丹(生命-=1000 攻击力+=500 魔法+=500 灵力+=100 50000元) 4.返回"<<endl;
cout<<"请选择(购买后直接使用)";
cin>>in;
if(in==1){
if(jb>=5){
sm+=50;
jb-=5;
js();
}else{
cout<<"您钱不够,先打怪吧";
system("cls");
js();
}
}
if(in==2){
if(jb>=500){
sm+=50;
jb-=500;
js();
}else{
cout<<"您钱不够,先打怪吧";
system("cls");
js();
}
}
if(in==3){
if(jb>=50000){
sm+=50;
jb-=50000;
js();
}else{
cout<<"您钱不够,先打怪吧";
system("cls");
js();
}
}
if(in==4){
system("cls");
game();
}
return ;
}
void kj(){
system("cls");
cout<<"血量:"<<sm<<"\t"<<"攻击:"<<gj<<"\t魔法:"<<mf<<"\t金币"<<jb<<endl;
cout<<"1、返回";
cin>>in;
if(in==1) game();
else cout<<"好好玩!";
}
int action(){
cout<<"\t\t\t\t\t\t"<<"欢迎来到'玄武世界'";
system("pause") ;
system("cls");
cout<<"\t\t\t\t\t\t"<<"是否进入游戏?"<<"\n\t\t\t\t\t"<<"1.Yes"<<"\t\t\t"<<"2.No";
cout<<endl;
cin>>in;
return in;
}
void game(){
system("cls");
cout<<"你要去哪里?"<<endl;
cout<<"1、试炼场 //未开放2、森林外部 3、森林内部 4.火山 5.冰川 6.集市 7.空间";
cin>>in;
if(in==1) slc();
if(in==2) slwb();
if(in==3) slnb();
if(in==4) hs();
if(in==5) bc();
if(in==6) js();
if(in==7) kj();
return ;
}
int main(){
srand((int)time(0));
if(action()==1){
system("cls");
cout<<"你是一个穿越者,来到了玄武世界……";
system("pause");
game();
}else{
cout<<"bye";
return 0;
}
return 0;
}
请各位古名look一下,某些功能暂不开放,我就码了一晚上,有细节问题,私信我相信有很多的