黑马程序员技术交流社区
标题:
案例001
[打印本页]
作者:
wdjzhuhuo
时间:
2017-3-21 00:06
标题:
案例001
package com.itheima.test04;
public class Test01 {
public static void main(String[] args) {
/* A. 定义一个数组,存储以下信息:
78 23 56 89 88 84 72 99 56 72 100 53 28
B. 求数组中所有偶数的和*/
int[] arr = {78,23,56,89,88,84,72,99,56,72,100,53,28};
int temp = 0;
int count = 0;
for(int i = 0; i<arr.length;i++){
if(arr[i]%2==0){
temp +=arr[i];
count++;
}
}
System.out.println(temp);
System.out.println(count);
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2