才学java,写了求素数的小程序,直接卡死。
package Isprime;
public class Isprime {
public static void main(String[] args) {
int max=10000;
boolean [] isPrime=new boolean [max+1];
for(int i = 0;i
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
当i等于0时候,j也为0,
j += 2*i永远为0,因此j永远是<=max的,因此死循环了。楼上已经给出答案了,碰到这种问题首先应该debug