标签:health craft 会同 ios for 第一个 tac tin mes
#include <iostream> #include <string> using namespace std; int main() { struct attendant{ int exist; //是否存在空位 int health; //随从生命值 int attack; //随从攻击力 }; attendant player1[8],player2[8]; for(int i = 1;i <= 7;i++) { player1[i].exist = 0; } for(int i = 1;i <= 7;i++) { player2[i].exist = 0; } int n,Player1 = 30,Player2 = 30,flag = 1,pos,attack,health; string symbol; cin >> n; while(n--) { cin >> symbol; if(flag % 2 == 1) { if(symbol=="summon") { cin >> pos; cin >> attack; cin >> health; if(Player1 <= 0 || Player2 <= 0) //判断游戏是否已经结束 { continue; } if(player1[pos].exist == 0) { player1[pos].exist = 1; player1[pos].attack = attack; player1[pos].health = health; } else { for(int i = 6;i >= pos;i--) { player1[i + 1].exist = player1[i].exist; player1[i + 1].attack = player1[i].attack; player1[i + 1].health = player1[i].health; } player1[pos].exist = 1; player1[pos].attack = attack; player1[pos].health = health; } } else if(symbol == "attack") { int gong,sou; cin >> gong; cin >> sou; if(Player1 <= 0 || Player2 <= 0) { continue; } if(sou != 0) { player1[gong].health = player1[gong].health - player2[sou].attack; player2[sou].health = player2[sou].health - player1[gong].attack; if(player1[gong].health <= 0 && gong == 7) { player1[gong].exist = 0; } else if(player1[gong].health <= 0 && gong < 7) { for(int i = gong + 1;i <= 7;i++) { player1[i - 1].exist = player1[i].exist; player1[i].exist = 0; player1[i - 1].health = player1[i].health; player1[i - 1].attack = player1[i].attack; } } if(player2[sou].health <= 0 && sou == 7) { player2[sou].exist = 0; } else if(player2[sou].health <= 0 && sou < 7) { for(int i = sou + 1;i <= 7;i++) { player2[i - 1].exist = player2[i].exist; player2[i - 1].health = player2[i].health; player2[i - 1].attack = player2[i].attack; } } } else { Player2 = Player2 - player1[gong].attack; } } else if(symbol == "end") { flag = flag + 1; } }
// 玩家二回合 else if(flag % 2 == 0) { if(symbol=="summon") { cin >> pos; cin >> attack; cin >> health; if(Player1 <= 0 || Player2 <= 0) { continue; } if(player2[pos].exist == 0) { player2[pos].exist = 1; player2[pos].attack = attack; player2[pos].health = health; } else { for(int i = 6;i >= pos;i--) { player2[i + 1].exist = player2[i].exist; player2[i].exist = 0; player2[i + 1].attack = player2[i].attack; player2[i + 1].health = player2[i].health; } player2[pos].exist = 1; player2[pos].attack = attack; player2[pos].health = health; } } else if(symbol == "attack") { int gong,sou; cin >> gong; cin >> sou; if(Player1 <= 0 || Player2 <= 0) { continue; } if(sou != 0) { player2[gong].health = player2[gong].health - player1[sou].attack; player1[sou].health = player1[sou].health - player2[gong].attack; if(player2[gong].health <= 0 && gong == 7) { player2[gong].exist = 0; } else if(player2[gong].health <= 0 && gong < 7) { for(int i = gong + 1;i <= 7;i++) { player2[i - 1].exist = player2[i].exist; player2[i - 1].health = player2[i].health; player2[i - 1].attack = player2[i].attack; } } if(player1[sou].health <= 0 && sou == 7) { player1[sou].exist = 0; } else if(player1[sou].health <= 0 && sou < 7) { for(int i = sou + 1;i <= 7;i++) { player1[i - 1].exist = player1[i].exist; player1[i - 1].health = player1[i].health; player1[i - 1].attack = player1[i].attack; } } } else { Player1 = Player1 - player2[gong].attack; } } else if(symbol == "end") { flag = flag + 1; } } } int count1 = 0,count2 = 0; //记录随从数量 for(int i = 1;i <= 7;i++) { if(player1[i].exist == 1) { count1++; } } for(int i = 1;i <= 7;i++) { if(player2[i].exist == 1) { count2++; } } if(Player1 <= 0) { cout << "-1" << "\n"; } else if(Player2 <= 0) { cout << "1" << "\n"; } else { cout << "0" << "\n"; } cout << Player1 << "\n"; cout << count1 << " "; if(count1 > 0) { for(int i = 1;i <= 7;i++) { if(player1[i].exist == 1) { cout << player1[i].health <<" "; } } cout << "\n"; } else { cout << "\n"; } cout << Player2 << "\n"; cout << count2 << " "; if(count2 > 0) { for(int i = 1;i <= 7;i++) { if(player2[i].exist == 1) { cout << player2[i].health <<" "; } } cout << "\n"; } else { cout << "\n"; } return 0; }
标签:health craft 会同 ios for 第一个 tac tin mes
原文地址:https://www.cnblogs.com/Lazy-Cat/p/9998497.html