?為什么最后得到的是5050,成了1到100加和了?
package com.imooc;
public class HelloWorld {
?public static void main(String[]args){
??int sum=0;
??for(int i=1;i<=100;i++){
???if(i%3!=0);{
???sum=sum+i;//累加求和
???}
??}
???System.out.println(sum)
}
}
package com.imooc;
public class HelloWorld {
?public static void main(String[]args){
??int sum=0;
??for(int i=1;i<=100;i++){
???if(i%3!=0);{
???sum=sum+i;//累加求和
???}
??}
???System.out.println(sum)
}
}
2020-02-15
舉報
2020-02-15
if(i%3!=0)其后不能加;