package com.chen.struct;
public class ForDemo02 {
public static void main(String[] args) {
//练习一:计算0到100之间奇数和偶数的和
int oddsum = 0;
int evensum = 0;
for (int i = 0; i < 100; i++) {
if (i%2!=0){//奇数
oddsum += i;
}else {//偶数
evensum += i;
}
}
System.out.println("奇数的和:"+oddsum);
System.out.println("偶数的和:"+evensum);
}
}
标签:Struct,奇数,int,偶数,evensum,oddsum From: https://www.cnblogs.com/jingyichenloveningning/p/17780298.html