021 魔兽世界之二:装备

#include <iomanip>
#include <iostream>
#include <string>
using namespace std;

static 	int n;
static int nowCase = 1;
static int* sumBloodArr;
static int(*manBloodArr)[5];
const string manName[5] = { "dragon","ninja","iceman","lion","wolf" }; 
static int weapon[3] = { 0,1,2 };
const string wpName[3] = { "sword", "bomb" ,"arrow"};
const int redManSort[5] = {2,3,4,1,0};
const int blueManSort[5] = {3,0,1,2,4};

class Man {
public:
	int manNo;
	int yun;
};
//0
class Dragon :public Man {
public:
	int wp;
	int zhiQi;

};
//1
class Ninja :public Man {
public:
	int wp[2];
	

};
//2
class Iceman :public Man {
public:
	int wp;
	

};
//3
class Lion :public Man {
public:
	int zc;

};
//4
class Wolf :public Man {
public:

};

class Base {
public:
	int preYun;
	int manCount[5] = {0,0,0,0,0};
	bool endCreatFlag = true;
	Man man;
	Base() {}
	Base(int pyun):preYun(pyun) {}
	//void createMan() {
	//}

};
class RedBase :public Base {
public :
	RedBase() {}
	RedBase(int pyun):Base(pyun) {}
	int nowMan = 0;
	int noMan = 1;
	
	void createMan() {
		int i;
		for (i = 0; i < 5; ++i) {
			if (preYun >= manBloodArr[nowCase-1][redManSort[nowMan]]) {
				preYun -= manBloodArr[nowCase-1][redManSort[nowMan]];
				
				manCount[nowMan]++;
				//cout << nowMan << endl;
				cout << " red " << manName[redManSort[nowMan]] << " " << noMan << " born with strength " << manBloodArr[nowCase-1][redManSort[nowMan]] << "," << manCount[nowMan] << " " << manName[redManSort[nowMan]] << " in red headquarter" << endl;
				switch (redManSort[nowMan]) {
					/* It has a arrow, and it's morale is 23.34
						表示该dragon降生时得到了arrow, 其士气是23.34(为简单起见,本题中arrow前面的冠词用a, 不用an,士气精确到小数点后面2位,四舍五入)
						如果造出的是ninja,那么还要输出一行,例:
						It has a bomband a arrow
						表示该ninja降生时得到了bomb和arrow。
						如果造出的是iceman,那么还要输出一行,例:
						It has a sword
						表示该iceman降生时得到了sword。
						如果造出的是lion,那么还要输出一行,例:
						It's loyalty is 24*/
				case 0:
					//It has a arrow,and it's morale is 23.34
					cout << "It has a " <<  wpName[noMan % 3] << ",and it's morale is " << fixed << setprecision(2) << preYun*1.0/ manBloodArr[nowCase - 1][redManSort[nowMan]] << endl;
					break;
				case 1:
					//It has a bomb and a arrow
					cout << "It has a " << wpName[noMan % 3] << " and a " << wpName[(noMan+1) % 3] << endl;
					break;
				case 2:
					//It has a sword
					cout << "It has a " << wpName[noMan % 3] << endl;
					break;
				case 3:
					//It's loyalty is 24
					cout << "It's loyalty is " << preYun <<endl;
					break;
				case 4:
					
					break;

				}
					

				nowMan = (nowMan + 1) % 5;
				noMan++;
				
				break;
			}
			else {
				nowMan = (nowMan + 1) % 5;
			}
		}
		if (i >= 5) {
			endCreatFlag = false;
			cout << " red headquarter stops making warriors" << endl;
		}
		
	}
};

class BlueBase :public Base {
public:
	BlueBase() {}
	BlueBase(int pyun) :Base(pyun) {}
	int nowMan = 0;
	int noMan = 1;

	void createMan() {
		int i;
		for (i = 0; i < 5; ++i) {
			if (preYun >= manBloodArr[nowCase - 1][blueManSort[nowMan]]) {
				preYun -= manBloodArr[nowCase - 1][blueManSort[nowMan]];

				manCount[nowMan]++;
				//cout << nowMan << endl;
				cout << " blue " << manName[blueManSort[nowMan]] << " " << noMan << " born with strength " << manBloodArr[nowCase - 1][blueManSort[nowMan]] << "," << manCount[nowMan] << " " << manName[blueManSort[nowMan]] << " in blue headquarter" << endl;
				switch (blueManSort[nowMan]) {
				case 0:
					//It has a arrow,and it's morale is 23.34
					cout << "It has a " << wpName[noMan % 3] << ",and it's morale is " << fixed << setprecision(2) << preYun * 1.0 / manBloodArr[nowCase - 1][blueManSort[nowMan]] << endl;
					break;
				case 1:
					//It has a bomb and a arrow
					cout << "It has a " << wpName[noMan % 3] << " and a " << wpName[(noMan + 1) % 3] << endl;
					break;
				case 2:
					//It has a sword
					cout << "It has a " << wpName[noMan % 3] << endl;
					break;
				case 3:
					//It's loyalty is 24
					cout << "It's loyalty is " << preYun << endl;
					break;
				case 4:

					break;

				}


				nowMan = (nowMan + 1) % 5;
				noMan++;

				break;
			}
			else {
				nowMan = (nowMan + 1) % 5;
			}
		}
		if (i >= 5) {
			endCreatFlag = false;
			cout << " blue headquarter stops making warriors" << endl;
		}

	}
};

/*
1
20
3 4 5 6 7
*/
//red dragon 1 born with strength -33686019,-858993459 dragon in red headquarter
// It has a arrow,and it's morale is 23.34

string getTime(int n) {
	if (n == 0) return "000";
	string res = "";
	res = to_string(n);
	if (res.length() == 1) res = "00" + res;
	if (res.length() == 2) res = "0" + res;

	return res;

}

int main() {
	cin >> n;
	sumBloodArr = new int[n];
	manBloodArr = new int[n][5];
	for (int i = 0; i < n; ++i) {
		cin >> sumBloodArr[i];
		for (int j = 0;j < 5;++j) {
			cin >> manBloodArr[i][j];
		}
	}
	for (int i = 0;i < n;++i) {
		int tm = 0;
		cout << "Case:" << i + 1 << endl;
		RedBase rbase(sumBloodArr[i]);
		BlueBase bbase(sumBloodArr[i]);
		while (rbase.endCreatFlag || bbase.endCreatFlag) {
			if (rbase.endCreatFlag) {
				cout << getTime(tm);
				rbase.createMan();
			}
			if (bbase.endCreatFlag) {
				cout << getTime(tm);
				bbase.createMan();
			}
			
			tm++;
		}
		nowCase++;

	}

	delete[] sumBloodArr;
	delete[] manBloodArr;
}
posted @ 2022-02-22 10:08  icefield817  阅读(75)  评论(0编辑  收藏  举报