推荐答案 4月1日晚上8:51,Scott < scle ... @ gmail.comwrote:On Apr 1, 8:51 pm, "Scott" <[email protected]: 现在这个没有任何意义我。我有一段时间 循环,它没有像它想象的那样工作。我将 放在下面。 ------------------------ - 计数= 1; 而(计数 { 如果(count == 1)rating2 = security; if(count == 2)rating2 = health; if(count == 3)rating2 = security;Hi, Now this one does not make any sense to me at all. I have a whileloop and it is not working anything like it is suppose to. I haveplaced it below.-------------------------Count = 1;while(count < 4) { if(count == 1) rating2 = security; if(count == 2) rating2 = health; if(count == 3) rating2 = security; [...][...] if(count = 1)fhealth = fhealth + bonus; 如果(计数= 3)经济=经济+奖金; if (count = 1) fhealth = fhealth + bonus; if (count = 2) feconomy = feconomy + bonus; if (count = 3) feconomy = feconomy + bonus; [...][...] if(count = 1)fhealth = fhealth + bonus; 如果(计数= 3)经济=经济+奖金; if (count = 1) fhealth = fhealth + bonus; if (count = 2) feconomy = feconomy + bonus; if (count = 3) feconomy = feconomy + bonus; 你在第一组if条件中看到了什么不同, 当你把它们与第二组和第三组进行比较时? :)Do you see anything different in the first group of if conditions,when you compare them to the second and third? :) Count = 1; [snip]Count = 1;[snip] if(count> = 2) if (count >= 2) 标识符区分大小写。如果您复制并粘贴了代码,请尝试 修复该代码。Identifiers are case sensitive. If you copied and pasted the code, tryfixing that. 4月1日,21:51,Scott < scle ... @ gmail.comwrote:On 1 Apr, 21:51, "Scott" <[email protected]: 现在这个没有任何意义我。我有一段时间 循环,它没有像它想象的那样工作。我将 放在下面。 ------------------------ - 计数= 1; 而(计数 { 如果(count == 1)rating2 = security; if(count == 2)rating2 = health; if(count == 3)rating2 = security; bonus =(rating2 / 10) - 5; bonus2 = 10 *(rating2 - ((奖励+5)* 10)); if(bonus2< 0) { bonus--; bonus2 = bonus2 + 100; } srand((无符号)时间(NULL)); roll = rand()/(int)(((unsigned)RAND_MAX + 1) / 100); if(bonus2> = roll)bonus ++; if(count = 1)fhealth = fhealth + bonus; if(count = 2)feconomy = feconomy + bonus; if(count = 3)feconomy = feconomy + bo新加坡国立大学;Hi, Now this one does not make any sense to me at all. I have a whileloop and it is not working anything like it is suppose to. I haveplaced it below.-------------------------Count = 1;while(count < 4) { if(count == 1) rating2 = security; if(count == 2) rating2 = health; if(count == 3) rating2 = security; bonus = (rating2 / 10) - 5; bonus2 = 10 * (rating2 - ((bonus + 5) * 10)); if (bonus2 < 0) { bonus--; bonus2 = bonus2 + 100; } srand((unsigned) time(NULL)); roll = rand()/(int)(((unsigned)RAND_MAX + 1) / 100); if (bonus2 >= roll) bonus++; if (count = 1) fhealth = fhealth + bonus; if (count = 2) feconomy = feconomy + bonus; if (count = 3) feconomy = feconomy + bonus; 在上面的3行中你有作业而不是比较。 我建议你开始使用像spint这样的代码检查工具;它将会收起这样的愚蠢错误。In the 3 lines above you have assignment instead of comparison.I suggest you start using a code checking tool like spint ; it willpick up silly mistakes like that. 这篇关于奇怪的同时和如果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 16:38