在家没事打的,不喜勿喷。
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
double g=100,mg,gs;
double maxn=-1,minn=1000000;
int itm,itn;
int main(){
srand((unsigned)time(NULL));
cin>>mg;
gs=mg/100;
cout<<"股数:"<<gs<<endl;
Sleep(1000);
for(int i=1;;i++){
int zj=rand()%2+1;
if(zj==1){
int c1=rand()%100+1;
double cx1=c1;
cx1/=10000;
g+=g*cx1;
}
else if(zj==2){
int c2=rand()%100+1;
double cx2=c2;
cx2/=10000;
g-=g*cx2;
}
cout<<i<<": 股价:"<<g<<" ";
if(g>maxn)itm=i;
if(g<minn)itn=i;
maxn=max(maxn,g);
minn=min(minn,g);
double zcc=g*gs;
cout<<"资产:"<<zcc;
cout<<" 最高:"<<maxn<<"("<<itm<<")";
cout<<" 最低:"<<minn<<"("<<itn<<")"<<endl;
Sleep(1000);
}
return 0;
}