求1-50的偶数和,和奇数和

public static void main(String args[]){

int doubleNumber = 0;

int  singleNumber = 0;

int i =1;

 

while(i <= 50){

if(i %2==0){

doubleNumber+=i;

}else{

singNumber+=i;

 

}

i++;

}

System.out.println(doubeNumber);

System.out.println(singleNumber);

}

posted on 2017-09-29 19:52  JETIME庚  阅读(1472)  评论(0编辑  收藏  举报

导航