#include using namespace std; struct Hero{ int life = 10000; int attack = 10; }; struct Monster{ int life = 10000; int attack = 100; }; int main(){ Hero h; Monster m; cout << "Hero的血量内存地址为:" << &h.life << endl; cout << "Hero的攻击力内存地址为:" << &h.attack << endl; cout << "Monster的血量内存地址为:" << &m.life << endl; cout << "Monster的攻击力内存地址为:" << &m.attack << endl; system("pause"); int count = 0; while(true){ if(m.life <= 0){ cout << "玩家打败了怪物!" << endl; break; } if(h.life <= 0){ cout << "怪物打败了玩家!" << endl; break; } h.life -= m.attack; m.life -= h.attack; cout << "--------第<< count << "次攻击-----------"; cout << "玩家对怪物造成了:" << h.attack << "点伤害" << endl; cout << "怪物对玩家造成了:" << m.attack << "点伤害" << endl; cout << "玩家血量:" << h.life << endl; cout << "怪物血量:" << m.life << endl; cout << endl; _sleep(5000); } }