不会是要这样吧?int m = 0;//存放最终结果 int n = 0; while ((++n) <= 100) { m += n; }
//:用while实现1+到100 public class TestWhile { public static void main(String[] arg){ //最终结果N int n = 0 ; //使用M控制循环 int m = 0 ; while (m <= 99) { n = ++n + m ; m++; } System.out.println("the note must to be" + n); } }///:~编译通过
int n = 0;
while ((++n) <= 100)
{
m += n;
}
public class TestWhile {
public static void main(String[] arg){
//最终结果N
int n = 0 ;
//使用M控制循环
int m = 0 ;
while (m <= 99) {
n = ++n + m ;
m++;
}
System.out.println("the note must to be" + n);
}
}///:~编译通过