初级守护
国家排名1.3.1版本来喽!!!
详细见酷丁平台作品:国家排名1.3.1
源代码:
#include<iostream>
#include<windows.h>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<ctime>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
int main(){
srand((unsigned)time(NULL));
long double h[50000],n=0,h1,u=100,k,nst,sshi=0,nos=0,zongs,bzsl,zrsl;
long long hk[100],sss=0;
string l[1000],o;
cout<<"请输入国家数量:";
cin>>h1;
cout<<"请输入数字(可提升国家实力的增长率,推荐100):";
cin>>hk[1];
cout<<"请输入数字(可提升国家实力的亏损率,推荐60):";
cin>>hk[2];
cout<<"是否看超越信息(负数表示否,0或0正数表示是):";
cin>>nst;
hk[2]=hk[2]-hk[2]-hk[2];
for(long long i=1;i<=h1;i++){
system("cls");
cout<<"请输入国家名称:("<<i<<"/"<<h1<<")";
cin>>l[i];
h[i]=10000;
if(l[i]=="英国")h[i]=10000000;
if(l[i]=="德国")h[i]=7000000;
if(l[i]=="**")h[i]=15000000;
if(l[i]=="**")h[i]=70000000;
if(l[i]=="**")h[i]=80000000;
if(l[i]=="荷兰")h[i]=2000000;
if(l[i]=="比利时")h[i]=1000000;
if(l[i]=="中国")h[i]=70000000;
if(l[i]=="波兰")h[i]=8000000;
if(l[i]=="**")h[i]=10000000;
if(l[i]=="加拿大")h[i]=12000000;
if(l[i]=="西班牙")h[i]=9000000;
if(l[i]=="丧尸"){
h[i]=10;
sss++;
}
if(l[i]=="(被淘汰)")l[i]="违规名字,以普通国家算";
}
while(1){
system("cls");
zongs=0;
for(long long i=1;i<h1;i++){
for(long long j=i+1;j<=h1;j++){
if(h[i]<h[j]){
if(l[j]=="丧尸"){
l[i]="丧尸";
sss++;
}
swap(h[i],h[j]);
swap(l[i],l[j]);
if(nst<0){
continue;
}
cout<<l[j]<<" 超越了 "<<l[i]<<endl;
}
}
}
cout<<setprecision(0)<<fixed<<u<<"年\n";
for(long long i=1;i<=h1;i++){
cout<<"第"<<i<<"名:"<<l[i]<<" "<<"实力:"<<setprecision(2)<<fixed<<h[i]<<endl;
if(i==1){
o=l[i];
bzsl=h[i];
}
if(i==h1){
zrsl=h[i];
}
zongs+=h[i];
if(l[i]=="丧尸"&&sss%2==0)h[i]*=0.9;
if(h[i]<=0.5){
l[i]="(被淘汰)";
h[i]=-1;
}
}
u++;
for(long long i=1;i<=h1;i++){
h[i]+=h[i]*(random(hk[2],hk[1])/99.999);
}
cout<<"世界霸主是:"<<o<<"\n"<<"世界霸主实力比例:"<<setprecision(2)<<fixed<<bzsl/zongs*100<<"%\n"<<"最弱国家实力比例:"<<zrsl/zongs*100<<"%\n"<<"所有国家总实力:"<<zongs<<"\n";
if(o=="丧尸"){
cout<<"丧尸胜利";
Sleep(2000);
return 0;
}
systyouem("pause");
}
cout<<endl;
system("pause");
return 0;
}