#include using namespace std; int hp[10], n, x; void one() { for (int i = 1; i <= 5; i++) { hp[i] = max(hp[i] - 5, 0); } } void two() { int max_hp = 0; for (int i = 1; i <= 5; i++) { max_hp = max(max_hp, hp[i]); } for (int i = 1; i <= 5; i++) { if (hp[i] == max_hp) { hp[i] = 0; break; } } } int main() { for (int i = 1; i <= 5; i++) { cin >> hp[i]; } cin >> n; for (int i = 1; i <= n; i++) { cin >> x; if (x == 1) { one(); } else if (x == 2) { two(); } } for (int i = 1; i <= 5; i++) { cout << hp[i] << ' '; } return 0; }

C++ 编程题:小核桃的攻击

原文地址: https://www.cveoy.top/t/topic/qe5p 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录