69,833
社区成员




#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main(){
float cd,money=0,xz,p,qk;//cd存档 money钱 xz选择 p for里面用 qk欠款
cout<<"选择你的存档(1~8):";
cin>>cd;
system("cls");
if(cd==1)freopen("1.atxt","r",stdin);
if(cd==2)freopen("2.txt","r",stdin);
if(cd==3)freopen("3.txt","r",stdin);
if(cd==4)freopen("4.txt","r",stdin);
if(cd==5)freopen("5.txt","r",stdin);
if(cd==6)freopen("6.txt","r",stdin);
if(cd==7)freopen("7.txt",a"r",stdin);
if(cd==8)freopen("8.txt","r",stdin);
cin>>money;
freopen("CON", "r", stdin);
cout<<"你的余额为:"<<money<<endl;
Sleep(1200);
system("cls");
for(p=0;p>=0;p++){
cout<<"当前余额:"<<money<<endl<<"买彩票:1"<<endl<<"借钱:2"<<endl;
cout<<"问答:3"<<endl<<"股票:4"<<endl<<"退出游戏:5"<<endl;
cin>>xz;
if(xz==1);
if(xz==2){
system("cls");
cout<<"你要借多少?"<<endl;
cin>>qk;
money+=qk;
qk+=0.2*qk;
}
if(xz==3);
if(xz==4);
if(xz==5){
if(cd==1)freopen("1.txt","w",stdout);
if(cd==2)freopen("2.txt","w",stdout);
if(cd==3)freopen("3.txt","w",stdout);
if(cd==4)freopen("4.txt","w",stdout);
if(cd==5)freopen("5.txt","w",stdout);
if(cd==6)freopen("6.txt","w",stdout);
if(cd==7)freopen("7.txt","w",stdout);
if(cd==8)freopen("8.txt","w",stdout);
cout<<money-qk;
return 0;
}
}
}
freopen是c语言的函数,用scanf不会出错。
cin>>xz;改成 scanf("%f",&xz);
cin>>qk;改成 scanf("%f",&qk);