想问一下,为什么将if改成while不行?
public class Shoushou {
public static void main(String[] args) {
int sum=0;
for(int i=1;i<=100;i++) {
while(i%3!=0) {
sum=sum+i;
}
}
System.out.println(sum);
}
}
public class Shoushou {
public static void main(String[] args) {
int sum=0;
for(int i=1;i<=100;i++) {
while(i%3!=0) {
sum=sum+i;
}
}
System.out.println(sum);
}
}
2020-05-16
举报