虽然循环条件不起作用

时间:2013-12-29 22:32:59

标签: c++

基本上,healthtwo的条件导致程序停止但由于某种原因而不是健康状况

完整代码:http://en.textsave.org/CmN

if (chance<=rando) {
   cout << " " << endl;
   cout << "Hit! Dealing " << attackp << " Damage!" << endl;
   healthtwo=healthtwo-attackp;
}
else {
       cout << " " << endl;
       cout << "Miss!" << endl;
}

chance=1+rand()%23;
if (chance<=rando) {
   cout << "Comp Used " << comattackname << "!" << " Hit!" << " Dealing " << attackcp << " Damage" << endl;
   cout << " " << endl;
   healthone=healthone-attackcp;
}
else {
   cout << "Comp Used " << comattackname << "!" << " Miss!" << endl;
   cout << " " << endl;
}


} while (healthone>=0 || healthtwo>=0);

1 个答案:

答案 0 :(得分:1)

这应该是合乎逻辑的&&)。毕竟,你想检查两个参赛者的健康状况是否大于或等于零。