#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int dragonStrength, ninjaStrength,icemanStrength,lionStrength,wolfStrength;
int test, headquarterLife;
string timeNow;
void increasetimeNow(){
if(timeNow[2]!='9')
timeNow[2]++;
else if(timeNow[1]!='9'){
timeNow[1]++;
timeNow[2]='0';
}
else{
timeNow[0]++;
timeNow[1]='0';
timeNow[2]='0';
}
}
class Headquarter{
string color;
int life;
int warriorNumber;
int dragonNumber;
int ninjaNumber;
int icemanNumber;
int lionNumber;
int wolfNumber;
bool makeDragon();
bool makeNinja();
bool makeIceman();
bool makeLion();
bool makeWolf();
bool isDragonMade;
bool isNinjaMade;
bool isIcemanMade;
bool isLionMade;
bool isWolfMade;
public:
bool stop;
void makeWorrior();
Headquarter(string color_);
};
Headquarter::Headquarter(string color_){
life = headquarterLife;
stop = false;
color = color_;
warriorNumber = 0;
dragonNumber = 0;
ninjaNumber = 0;
icemanNumber = 0;
lionNumber = 0;
wolfNumber = 0;
isDragonMade = false;
isNinjaMade = false;
isIcemanMade = false;
isLionMade = false;
isWolfMade = false;
if(color_=="red")
isDragonMade = true;
else
isWolfMade = true;
}
bool Headquarter::makeDragon(){
isDragonMade = true;
if(life>= dragonStrength){
life -= dragonStrength;
warriorNumber ++;
dragonNumber ++;
cout << timeNow << " " << color<<" dragon" << " " << warriorNumber<<" born withstrength ";
cout << dragonStrength<<"," << dragonNumber<< " dragon in"<< color <<"headquarter" << endl;
return true;
}
return false;
}
bool Headquarter::makeNinja(){
isNinjaMade = true;
if(life>= ninjaStrength){
life -= ninjaStrength;
warriorNumber ++;
ninjaNumber ++;
cout << timeNow << " " << color<<" ninja" << " " << warriorNumber<<" born withstrength ";
cout << ninjaStrength << "," << ninjaNumber<<" ninja in" << color<< "headquarter"<< endl;
return true;
}
return false;
}
bool Headquarter::makeIceman(){
isIcemanMade = true;
if(life>= icemanStrength){
life -= icemanStrength;
warriorNumber ++;
icemanNumber ++;
cout << timeNow << " " << color<<" iceman" << " " << warriorNumber<<" born withstrength ";
cout << icemanStrength<<"," << icemanNumber<< " iceman in"<< color <<"headquarter" << endl;
return true;
}
return false;
}
bool Headquarter::makeWolf(){
isWolfMade = true;
if(life>= wolfStrength){
life -= wolfStrength;
warriorNumber ++;
wolfNumber ++;
cout << timeNow << " " << color<<" wolf" << " " << warriorNumber<<" born withstrength ";
cout << wolfStrength << "," << wolfNumber<<" wolf in" << color<< "headquarter"<< endl;
return true;
}
return false;
}
bool Headquarter::makeLion(){
isLionMade = true;
if(life>= lionStrength){
life -= lionStrength;
warriorNumber ++;
lionNumber ++;
cout << timeNow << " " << color<<" lion" << " " << warriorNumber<<" born withstrength ";
cout << lionStrength << "," << lionNumber<<" lion in" << color<< "headquarter"<< endl;
return true;
}
return false;
}
void Headquarter::makeWorrior(){
if(color=="red"){
if(isDragonMade){
isDragonMade = false;
if(makeIceman())
return;
}
if(isIcemanMade){
isIcemanMade = false;
if(makeLion())
return;
}
if(isLionMade){
isLionMade = false;
if(makeWolf())
return;
}
if(isWolfMade){
isWolfMade = false;
if(makeNinja())
return;
}
if(isNinjaMade){
isNinjaMade = false;
if(makeDragon())
return;
}
if(isDragonMade){
isDragonMade = false;
if(makeIceman())
return;
}
if(isIcemanMade){
isIcemanMade = false;
if(makeLion())
return;
}
if(isLionMade){
isLionMade = false;
if(makeWolf())
return;
}
if(isWolfMade){
isWolfMade = false;
if(makeNinja())
return;
}
if(isNinjaMade){
isNinjaMade = false;
if(makeDragon())
return;
}
stop = true;
cout << timeNow << " redheadquarter stops making warriors" << endl;
}
else{
if(isWolfMade){
isWolfMade = false;
if(makeLion())
return;
}
if(isLionMade){
isLionMade= false;
if(makeDragon())
return;
}
if(isDragonMade){
isDragonMade = false;
if(makeNinja())
return;
}
if(isNinjaMade){
isNinjaMade = false;
if(makeIceman())
return;
}
if(isIcemanMade){
isIcemanMade = false;
if(makeWolf())
return;
}
if(isWolfMade){
isWolfMade = false;
if(makeLion())
return;
}
if(isLionMade){
isLionMade = false;
if(makeDragon())
return;
}
if(isDragonMade){
isDragonMade = false;
if(makeNinja())
return;
}
if(isNinjaMade){
isNinjaMade = false;
if(makeIceman())
return;
}
if(isIcemanMade){
isIcemanMade = false;
if(makeWolf())
return;
}
stop = 1;
cout << timeNow << " blueheadquarter stops making warriors"<< endl;
}
}
void getInformation(){
scanf("%d",&headquarterLife);
scanf("%d %d %d %d%d",&dragonStrength,&ninjaStrength,&icemanStrength,&lionStrength,&wolfStrength);
}
int main(void){
scanf("%d",&test);
for(int i=0; i< test; i++){
timeNow = "000";
getInformation();
cout << "Case:" << i + 1 << endl;
Headquarter red("red");
Headquarter blue("blue");
while((!(red.stop)||!(blue.stop))){
if(!(red.stop))
red.makeWorrior();
if(!(blue.stop))
blue.makeWorrior();
increasetimeNow();
}
}
}
程设实习——魔兽世界一
最新推荐文章于 2020-02-27 19:04:04 发布