int sum=0;
int ouShu=0; int jiShu=0; int n=0; for (int i = 1; i <= 100; i++) { sum+=i; if(i%2==0){ ouShu+=i; } if(i%2!=0){ jiShu+=i; } if(i%7==0){ n+=i; } } System.out.println("1-100所有的数字和:"+sum); System.out.println("偶数和:"+ouShu); System.out.println("奇数和:"+jiShu); System.out.println("被7整除的数字和:"+n);