我不知道为什么这不会执行。有任何想法吗?我的语法是否错误或我未正确初始化计数?
这是代码:
int product = 0, count=0;
while (product < 2500){
product *= 5;
count++;
}
System.out.println(product);
product = 0
然后乘以5
product *= 5;
0 times 5 is still 0
所以
while (product < 2500){
永远是真的。考虑设置
product = 1
最初,以便它增长到足以退出while循环并在某个时候打印。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句