package com.lovcoding.day05.arr;

public class Test04ArrSuanFa01 {

    public static void main(String[] args) {
        //求平均值
        int[] arr = {10,23,34,56,61,23,102,208};

        //求和
        double sum = 0;

        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }

        System.out.println(sum/arr.length); //double
    }

    public static void main2(String[] args) {
        //统计个数
        //统计偶数的个数
        int[] arr = {10,23,34,56,61,23,102,208};

        //统计 出现 ++
        int count = 0;

        for (int i = 0; i < arr.length; i++) {
            if ( arr[i] % 2 == 0 ){
                count++;
            }
        }

        System.out.println(count);

    }
    public static void main1(String[] args) {
        //求和
        int[] arr = {10,23,34,56,61,23,102,208};

        //sum
        int sum = 0;

        //循环相加
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }

        System.out.println(sum);
    }
}
