魔兽 备战
来源:互联网 发布:网络质量测试工具 编辑:程序博客网 时间:2024/04/26 18:39
#include<iostream>
#include<iomanip>
#include<cstring>
using namespace std;
class headquarter{
public:
intflag;
intstop_flag;
charteam[5];
intcrystal;
intnum;
introle_num[5];
intsequence[5];
headquarter(inttm,int c):crystal(c),num(1),flag(0),stop_flag(0){
for(inti=0;i<5;i++){
role_num[i]=0;
}
if(tm==0){
strcpy(team,"red");
sequence[0]=2;
sequence[1]=3;
sequence[2]=4;
sequence[3]=1;
sequence[4]=0;
}
elseif (tm==1){
strcpy(team,"blue");
sequence[0]=3;
sequence[1]=0;
sequence[2]=1;
sequence[3]=2;
sequence[4]=4;
}
}
voidstop(int t,headquarter h){
cout<<setw(3)<<setfill('0')<<t<<''<<h.team<< " headquarter stops makingwarriors"<<endl;
};
friendclass warrior;
};
class warrior{
public:
charrole[10];
intstrength;
intatk;
warrior(intt,headquarter h,int p,int s){
if(h.sequence[p]==0)
strcpy(role,"dragon");
elseif(h.sequence[p]==1)
strcpy(role,"ninja");
elseif(h.sequence[p]==2)
strcpy(role,"iceman");
elseif(h.sequence[p]==3)
strcpy(role,"lion");
elseif(h.sequence[p]==4)
strcpy(role,"wolf");
cout<<setw(3)<<setfill('0')<<t<<''<<h.team<<' '<<role<<' '<<h.num<<"born with strength"<<s<<","<<h.role_num[h.sequence[p]]<<''<<role<<" in "<<h.team<<"headquarter"<<endl;
};
friendclass headquarter;
};
int main(){
//input data
int N;
cin>>N;
if (N<=0){
cout<<"ErrorImput"<<endl;
return -1;
}
for(int n=1;n<=N;n++){
inttime=0,M,df_strength[5];
cin>>M;
if(M>10000||M<1){
cout<<"ErrorImput"<<endl;
return-2;
}
for(inti=0;i<5;i++){
cin>>df_strength[i];
if(df_strength[i]>10000||df_strength[i]<=0){
cout<<"ErrorImput"<<endl;
return-3;
}
}
cout<<"Case:"<<n<<endl;
//prepare for war
headquarterred(0,M),blue(1,M);
for(inti=0,j=0;red.stop_flag!=1||blue.stop_flag!=1;time++){
if(red.stop_flag!=1){
if(red.crystal>=df_strength[red.sequence[i%5]]){
red.role_num[red.sequence[i%5]]++;
warrior(time,red,i%5,df_strength[red.sequence[i%5]]);
red.num++;
red.crystal-=df_strength[red.sequence[i%5]];
i++;
}
else if(red.crystal>=df_strength[red.sequence[(i+1)%5]]){
red.role_num[red.sequence[(i+1)%5]]++;
warrior(time,red,(i+1)%5,df_strength[red.sequence[(i+1)%5]]);
red.num++;
red.crystal-=df_strength[red.sequence[(i+1)%5]];
i=(i+1)+1; //next time,begin with next role
}
else if(red.crystal>=df_strength[red.sequence[(i+2)%5]]){
red.role_num[red.sequence[(i+2)%5]]++;
warrior(time,red,(i+2)%5,df_strength[red.sequence[(i+2)%5]]);
red.num++;
red.crystal-=df_strength[red.sequence[(i+2)%5]];
i=(i+2)+1;
}
else if(red.crystal>=df_strength[red.sequence[(i+3)%5]]){
red.role_num[red.sequence[(i+3)%5]]++;
warrior(time,red,(i+3)%5,df_strength[red.sequence[(i+3)%5]]);
red.num++;
red.crystal-=df_strength[red.sequence[(i+3)%5]];
i=(i+3)+1;
}
else if(red.crystal>=df_strength[red.sequence[(i+4)%5]]){
red.role_num[red.sequence[(i+4)%5]]++;
warrior(time,red,(i+4)%5,df_strength[red.sequence[(i+4)%5]]);
red.num++;
red.crystal-=df_strength[red.sequence[(i+4)%5]];
i=(i+4)+1;
}
else{
red.stop(time,red);
red.stop_flag=1;
}
}
if(blue.stop_flag!=1){
if(blue.crystal>=df_strength[blue.sequence[j%5]]){
blue.role_num[blue.sequence[j%5]]++;
warrior(time,blue,j%5,df_strength[blue.sequence[j%5]]);
blue.num++;
blue.crystal-=df_strength[blue.sequence[j%5]];
j++;
}
else if(blue.crystal>=df_strength[blue.sequence[(j+1)%5]]){
blue.role_num[blue.sequence[(j+1)%5]]++;
warrior(time,blue,(j+1)%5,df_strength[blue.sequence[(j+1)%5]]);
blue.num++;
blue.crystal-=df_strength[blue.sequence[(j+1)%5]];
j=(j+1)+1;
}
else if(blue.crystal>=df_strength[blue.sequence[(j+2)%5]]){
blue.role_num[blue.sequence[(j+2)%5]]++;
warrior(time,blue,(j+2)%5,df_strength[blue.sequence[(j+2)%5]]);
blue.num++;
blue.crystal-=df_strength[blue.sequence[(j+2)%5]];
j=(j+2)+1;
}
else if(blue.crystal>=df_strength[blue.sequence[(j+3)%5]]){
blue.role_num[blue.sequence[(j+3)%5]]++;
warrior(time,blue,(j+3)%5,df_strength[blue.sequence[(j+3)%5]]);
blue.num++;
blue.crystal-=df_strength[blue.sequence[(j+3)%5]];
j=(j+3)+1;
}
else if(blue.crystal>=df_strength[blue.sequence[(j+4)%5]]){
blue.role_num[blue.sequence[(j+4)%5]]++;
warrior(time,blue,(j+4)%5,df_strength[blue.sequence[(j+4)%5]]);
blue.num++;
blue.crystal-=df_strength[blue.sequence[(j+4)%5]];
j=(j+4)+1;
}
else{
blue.stop(time,blue);
blue.stop_flag=1;
}
}
}
}
return 0;
}
- 魔兽 备战
- 备战
- 备战
- 魔兽
- 备战SCWCD
- 备战程序员
- 备战中...
- 找工作备战
- 备战蓝桥杯中
- 备战阿里巴巴
- 资料备战
- 备战考试
- 备战笔记
- 备战GDOI
- 备战GDKOI2018
- 魔兽心得
- 魔兽图片
- 魔兽心情
- activiti自定义流程之整合(七):完成我的申请任务
- java 双色球(随机数:random)
- 使用SurfaceView播放gif动画
- Theserver is not reeady for publishing.Please check if the Publishing Tools on the serverare started
- iOS 动画Animation - 5:UIBezier
- 魔兽 备战
- Exception in thread "http-bio-8089-exec-8" java.lang.OutOfMemoryError: PermGen space
- Redis复制流程概述
- Java中的泛型
- (备忘录)Ubuntu基本环境搭建——超级本安装Ubuntu14.04.4 32bit
- JavaScript模块化规范
- 4.18省选模拟赛T3 道路 求一个图中的每一个最小生成树都必须包含的边的数量
- jQuery制作表单验证
- 汇编-求数组中所有偶数的和