编程语言
首页 > 编程语言> > JAVASE for 笔记

JAVASE for 笔记

作者:互联网

//0到100中奇数偶数的和
package com.huang.boke.flowPath;

public class Fordeme {
public static void main(String[] args) {

int oddSum = 0;
int evenSum = 0;
for (int i = 0; i < 100; i++) {

if(i % 2 == 0){
evenSum+=i;
}else {
oddSum += i;
}
}
System.out.println("偶数和"+evenSum);
System.out.println("奇数和"+oddSum);
}
}

标签:int,System,笔记,evenSum,oddSum,JAVASE,100,out
来源: https://www.cnblogs.com/spking/p/14374273.html