for循环:
public class For {
public static void main(String[] args) {
int sum = 0;
for (int i = 1 ; i <= 100 ; i++){
if (i % 2 ==0){
sum = sum + i;
}
}
System.out.println(sum);
}
while循环:
public class Chufa {标签:count,beichu,int,sum,java5,chu,public From: https://www.cnblogs.com/tqylqt/p/18168324
public static void main(String[] args) {
int chu = 5;
int beichu = 101;
int count = 0;
while (beichu > chu) {
beichu =beichu -chu;
count++;
}
System.out.println("结果:"+count+","+"余数:"+beichu);
}
}