1.循环语句while
while(循环条件){
执行语句
………
}
用while打印1-100;
int i=1;
while(i<=100){
System.out.println(i);
i++;
}
用while打印1-100的和;
int i=0; int count=0; while(i<=100){ count+=i; i++; }
System.out.println(count);
用while打印1-100的偶数和;(奇数在if判断改成 i%2==1);
int i=1;
int count=0;
while(i<=100){
if(i%2==0){
count+=i;
}
i++;
}
System.out.println(count);