-3
有人能解釋這個循環是如何工作的嗎?我很難理解它何時會運行if語句以及何時循環回去。這個while循環是如何工作的?
// keep buying phones while you still have money
while (amount < bank_balance) {
// buy a new phone!
amount = amount + PHONE_PRICE;
// can we afford the accessory?
if (amount < SPENDING_THRESHOLD) {
amount = amount + ACCESSORY_PRICE;
}
}
此外,爲什麼它仍然工作沒有其他組件與if?