Untitled

mail@pastecode.io avatar
unknown
java
3 years ago
538 B
29
Indexable
public class Average {
    public static void main(String[] args) {

        int arr[] = { 1, 2, 3, 4, 5, 6, 1, 10 };
        int average = 0;
        int remainder = 0;
        int len = arr.length;

        for (int i = 0; i < len; i++) {
            int q = arr[i] / len;
            int r = arr[i] % len;
            average = average + q;
            remainder += r;
        }
        if (remainder >= len) {
            average = average + remainder / len;
        }
        System.out.println(average);
    }
}