public static void main(String[] arg) {
System.out.println("100内的素数为:");
int k=0;
loop: for (int i = 2; i < 100; i++) {
for (int j = 2; j < i; j++) {
if (i % j == 0) {
continue loop;
}
}
k++;
if(k/5==k/5.0)
{
System.out.println(" " + i);
} else{
System.out.print(" " + i);
}
}
}
换行了。
public class Sushu {
public static void main(String[] args) {
System.out.println("100内的素数为:");
loop:
for (int i = 2; i < 100; i++) {
for (int j = 2; j < i; j++) {
if (i % j == 0) {
continue loop;
}
}
System.out.print(" " + i);
}
}
}