aboutsummaryrefslogtreecommitdiff
path: root/semestr-4/ask/lista6/puzzle8.c
blob: 4d65f9d7b893106419432902de13d1105e050703 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <limits.h>

struct T {
    long min;
    long max;
    long mean;
};

struct T puzzle8(long *a, long n);

struct T decode(long *a, long n) {
    long maks = LONG_MIN;
    long mini = LONG_MAX;
    long sum = 0;
    for (int i = 0; i < n; i++) {
        if (maks < a[i]) maks = a[i];
        if (mini > a[i]) mini = a[i];
        sum += a[i]; 
    }
    struct T ret;
    ret.min = mini;
    ret.max = maks;
    ret.mean = sum / n;
    return ret;
}