public class EvenNumberSum {public static void main(String[] args) {// 定义变量sum来保存偶数的和int sum = 0;// 定义变量count来保存偶数的个数int count = 0;// 开始循环枚举1到100的整数for (int i = 1; i <= 100; i++) {// 判断当前数是否为偶数if (i % 2 == 0) {/...
public static void main(String args[]){ int x = 1, y = 0;int z = 0;while( x <= 100){ y = y+x;if(x % 2 == 0){ z = z + x;} x = x+1 } System.out.println(y + ", " + z);//数字之间要隔开,不然就相加了 } ...
public class TestEven1 { public static void main(String[] args){ TestEven1 te;int[] evenBeforeReverse;int[] evenAfterReverse;te = new TestEven1();evenBeforeReverse = te.evenNumber(100);evenAfterReverse = te.reverse(evenBeforeReverse);te.printArray(evenAfterReverse);} public int...
public static void main(String[] args) { int a[][] = new int[2][50]; //用二维数组保存,偶数和奇数就可以分开了 int j=0; //奇数行的计数 int k=0; //偶数行的计数 int count=0;while(count<50){ int num=(int)(Math.random()*100);if(num==0) continue;else if...