public class SumFor{
public static void main(String[] args){
int sum_odd = 0;
int sum_even = 0;
for(int i=1;i <=100;i++){
if(i % 2 == 0){
sum_even += i;
}
else{
sum_odd +=i;
}
}
System.out.println("100以内奇数和为:" + sum_odd + "\t" + "100以内偶数和为:" + sum_even);
}
}
public class EvenNumber{
public static void main(String[] args){
int i = 1;
int sum_odd = 0;
int sum_even = 0;
while(i <= 100){
if(i % 2 == 0){
//System.out.println(i);
sum_even += i;
}
else{
sum_odd += i;
}
i++;
}
System.out.println("100以内奇数和为:" + sum_odd + "\t" + "100以内偶数和为:" + sum_even);
}
}