void跳转出了问题,求解
想写一个游戏,可跳转不知出了什么问题,求解!代码:
程序代码:
#include<bits/stdc++.h> #include<windows.h> using namespace std; #define version "0.14.8" #define ut 10000000ll long long jbdg=0; long long tjdx=0; long long ggss=0; long long bx=0; long long ys=0; long long money=0; int redball[6],blueball; int redwinningball[6],bluewinningball; int ppp,ooo; int ballnumber=0; void print(string a) { for (int i=0;i<=a.length();++i) { cout<<a[i]; Sleep(25); } Sleep(1000); return; } void home() { system("cls"); print("你想去哪儿?");cout<<endl; print("1.商店 2.淘金场(领取每日奖励及工作) 3.买彩票 4.使用道具 5.查看状态 6.存档并退出"); int f; cin>>f; switch(f) { case 1: shop(); break; case 2: taojingchang(); break; case 3: caipiaozhan(); break; case 4: shiyong(); break; case 5: zhuangtai(); break; case 6: cundang(); break; default: print("请重新输入:"); home(); } } void delay(long long t) { for (int i=0;i<t;i++); return; } void welcome() { cout<<"彩票程序 version"<<version<<" by Windows C++ 程序工作室"<<endl; delay(40*ut); for (int i=0;i<=100;i++) { printf("加载中…… %d%%\r",i); delay(2*ut); } delay(30*ut); cout<<endl<<endl<<"加载完成!"<<endl; delay(60*ut); Sleep(1000); home(); } void taojingchang() { system("cls"); print("欢迎来到淘金场!") ; cout<<endl; print("输入“#”号前往领取每日奖励 输入“%”号前去打工") ; char s; cin>>s; Sleep(200); system("cls"); if(s=='#') { print("每日奖励:50金币"); cout<<endl; print("已为您自动领取!请去状态查看!"); money=money+50; print("即将返回首页……"); Sleep(1000); home(); } else if(s=='%') { print("请问你要打什么工?"); Sleep(500); system("cls"); print("工号:6022 搬砖(工作时间5秒)**************************30金币");cout<<endl; print("工号:9003 抹水泥(工作时间5秒)************************30金币");cout<<endl; print("工号:4831 计算师(工作时间7秒)************************70金币");cout<<endl; print("工号:1056 教师(工作时间10秒)************************100金币");cout<<endl; print("工号:2003 酒店服务员(工作时间15秒)******************130金币");cout<<endl; print("工号:4167 会计(工作时间30秒)************************150金币");cout<<endl; print("工号:9520 酿酒师(工作时间45秒)**********************200金币");cout<<endl; print("工号:4819 司机(工作时间1分钟)***********************230金币");cout<<endl; print("工号:2009 出纳(工作时间1分钟15秒)*******************245金币");cout<<endl; print("工号:8888 程序“猿”(工作时间2分钟)**一把钥匙(可开启宝箱)");cout<<endl; print("请输入你想要做的工种所对应的工号(输入其他返回首页)") ; int asd; cin>>asd; switch(asd) { case 6022: print("工作中……"); cout<<endl; Sleep(5000); money=money+30; print("金币已发放,请去“状态”中查看!");cout<<endl; print("2秒后返回首页……"); Sleep(2000); home(); break; case 9003: print("工作中……"); cout<<endl; Sleep(5000); money=money+30; print("金币已发放,请去“状态”中查看!");cout<<endl; print("2秒后返回首页……"); Sleep(2000); home(); break; case 4831: print("工作中……"); cout<<endl; Sleep(7000); money=money+70; print("金币已发放,请去“状态”中查看!");cout<<endl; print("2秒后返回首页……"); Sleep(2000); home(); break; case 1056: print("工作中……"); cout<<endl; Sleep(10000); money=money+100; print("金币已发放,请去“状态”中查看!");cout<<endl; print("2秒后返回首页……"); Sleep(2000); home(); break; case 2003: print("工作中……"); cout<<endl; Sleep(15000); money=money+130; print("金币已发放,请去“状态”中查看!");cout<<endl; print("2秒后返回首页……"); Sleep(2000); home(); break; case 4167: print("工作中……"); cout<<endl; Sleep(30000); money=money+150; print("金币已发放,请去“状态”中查看!");cout<<endl; print("2秒后返回首页……"); Sleep(2000); home(); break; case 9520: print("工作中……"); cout<<endl; Sleep(45000); money=money+200; print("金币已发放,请去“状态”中查看!");cout<<endl; print("2秒后返回首页……"); Sleep(2000); home(); break; case 4819: print("工作中……"); cout<<endl; Sleep(60000); money=money+230; print("金币已发放,请去“状态”中查看!");cout<<endl; print("2秒后返回首页……"); Sleep(2000); home(); break; case 2009: print("工作中……"); cout<<endl; Sleep(75000); money=money+245; print("金币已发放,请去“状态”中查看!");cout<<endl; print("2秒后返回首页……"); Sleep(2000); home(); break; case 8888: print("工作中……"); cout<<endl; Sleep(120000); ys=ys+1; print("钥匙已发放,请去“状态”中查看!");cout<<endl; print("2秒后返回首页……"); Sleep(2000); home(); break; default: home(); } } else { print("输入无效,返回淘金场"); taojingchang(); } } void caipiaozhan() { system("cls"); print("欢迎来到彩票站!");cout<<endl; print("请输入6个1~33的号码(红球区)");cout<<endl; for(int i=1;i<=6;++i) { cin>>redball[i]; if((redball[i]<1)||(redball[i]>33)) { print("对不起,你输入了一个违规的数,正在返回彩票站……"); Sleep(500); caipiaozhan(); } } Sleep(500); print("请输入一个1~16的号码(蓝球区)");cout<<endl; cin>>blueball; if((blueball<1)||(blueball>16)) { print("对不起,你输入了一个违规的数,正在返回彩票站……"); Sleep(500); caipiaozhan(); } for(int i=1;i<=6;++i) { srand(time(0)); ppp=rand()%33+1; redwinningball[i]=ppp; } srand(time(0)); ooo=rand()%33+1; bluewinningball=ooo; system("cls"); print("30秒后开奖……");cout<<endl; for(int i=1;i<=6;++i) { if(redball[1]==redwinningball[i]) { ballnumber=ballnumber+1; } } for(int i=1;i<=6;++i) { if(redball[2]==redwinningball[i]) { ballnumber=ballnumber+1; } } for(int i=1;i<=6;++i) { if(redball[3]==redwinningball[i]) { ballnumber=ballnumber+1; } } for(int i=1;i<=6;++i) { if(redball[4]==redwinningball[i]) { ballnumber=ballnumber+1; } } for(int i=1;i<=6;++i) { if(redball[5]==redwinningball[i]) { ballnumber=ballnumber+1; } } for(int i=1;i<=6;++i) { if(redball[6]==redwinningball[i]) { ballnumber=ballnumber+1; } } if(blueball==bluewinningball) { ballnumber=ballnumber+1; } Sleep(30000); print("开奖 Show Time!");cout<<endl; print("红球:");cout<<endl; for(int i=1;i<=6;++i) { cout<<redwinningball[i]; Sleep(500); } Sleep(5000); print("蓝球:");cout<<endl; cout<<bluewinningball; if(ballnumber==0) { cout<<"你没中奖,花费了2金币"; cout<<endl; money=money-2; Sleep(500); home(); } else if(ballnumber==1) { cout<<"你中了1个号码,获得5金币(赚了3金币)"<<endl; money=money-2+5; Sleep(500); home(); } else if(ballnumber==2) { cout<<"你中了2个号码,获得7金币(赚了5金币)"<<endl; money=money-2+7; Sleep(500); home(); } else if(ballnumber==3) { cout<<"你中了3个号码,获得20金币(赚了18金币)"<<endl; money=money-2+20; Sleep(500); home(); } else if(ballnumber==4) { cout<<"你中了4个号码,真是奇迹!获得100金币(赚了98金币)"<<endl; money=money-2+100; Sleep(500); home(); } else if(ballnumber==5) { cout<<"你中了5个号码,可以说是个传说。获得500金币(赚了498金币)"<<endl; money=money-2+500; Sleep(500); home(); } else if(ballnumber==6) { cout<<"你中了6个号码!惊呆了作者!获得一把钥匙!"<<endl; money=money-2; ys=ys+1; Sleep(500); home(); } else if(ballnumber==7) { cout<<"What happened!?我是不相信你能中7个号码!获得宝箱*1,钥匙*1!"<<endl; money=money-2; ys=ys+1; bx=bx+1; Sleep(500); home(); } } void shiyong() { system("cls"); print("1.加倍道具***********"); cout<<jbdg; print("个");cout<<endl; print("2.天降大喜***********"); cout<<tjdx; print("个");cout<<endl; print("3.鬼鬼祟祟***********"); cout<<ggss; print("4.宝箱***************"); cout<<bx; print("个");cout<<endl; print("钥匙*****************"); cout<<ys; print("把");cout<<endl; print("你要使用什么(输入编号,无效编号返回首页)(1~4)?"); int mm; cin>>mm; switch(mm) { case 1: if(jbdg>=1) { print("你使用了“加倍道具”,金币翻倍");cout<<endl; jbdg=jbdg-1; money=money*2; print("2秒后返回首页……"); Sleep(2000); home(); } else { print("道具不足,请前往购买,3秒后返回首页……"); Sleep(3000); home(); } break; case 2: if(tjdx>=1) { int temp1; srand(time(0)); temp1=rand()%1000+1; print("你使用了“天降大喜”,增加"); cout<<temp1; print("枚金币");cout<<endl; tjdx=tjdx-1; money=money+temp1; print("2秒后返回首页……"); Sleep(2000); home(); } else { print("道具不足,请前往购买,3秒后返回首页……"); Sleep(3000); home(); } break; case 3: int temp2; srand(time(0)); temp2=rand()%2+1; if(temp2==2) { if(ggss>=1) { int temp3; srand(time(0)); temp3=rand()%1000+1; print("恭喜你获得了") ; cout<<temp3; print("枚金币");cout<<endl; ggss=ggss-1; money=money+temp3; print("2秒后返回首页……"); Sleep(2000); home(); } else { print("道具不足,请前往购买,3秒后返回首页……"); Sleep(3000); home(); } } else { if(ggss>=1) { int temp3; srand(time(0)); temp3=rand()%1000+1; print("你损失了") ; cout<<temp3; print("枚金币");cout<<endl; ggss=ggss-1; money=money-temp3; print("2秒后返回首页……"); Sleep(2000); home(); } else { print("道具不足,请前往购买,3秒后返回首页……"); Sleep(3000); home(); } } break; case 4: if(bx>=1) { if(ys>=1) { int temp4; srand(time(0)); temp4=rand()%10+1; print("恭喜你获得了“加倍道具”"); cout<<temp4; print("个!");cout<<endl; jbdg=jbdg+temp4; print("2秒后返回首页……"); Sleep(2000); home(); } else { print("你没有钥匙,3秒后返回首页……"); Sleep(3000); home(); } } else { print("你没有宝箱,3秒后返回首页……"); Sleep(3000); home(); } break; default: home(); } } void zhuangtai() { print("你有"); cout<<money; print("枚金币");cout<<endl; print("3秒后返回首页……"); Sleep(3000); void home(); } void cundang() { print("存档中……");cout<<endl; ofstream out("D:\\HappyGames\\0.14.8\\archive.tmp"); out<<jbdg<<'\n'<<tjdx<<'\n'<<ggss<<'\n'<<bx<<'\n'<<ys<<'\n'<<money; out.close(); print("存档完成!"); } void dudang() { ifstream in("D:\\HappyGames\\0.14.8\\archive.tmp"); in>>jbdg>>tjdx>>ggss>>bx>>ys>>money; in.close(); welcome(); } int main() { dudang(); return 0; }
源文件
0.14.8.zip
(3.23 KB)