int i,sumj,sumo; for(i=1,sumj=0,sumo=0;i<=100;i++){ if(i%2==0){ sumo=sumo+i; } else{ sumj=sumj+i; } } System.out.println("奇数和为:"+sumj); System.out.println("偶数和为:"+sumo);