diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-04-17 17:31:46 +0200 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-04-17 17:31:46 +0200 |
commit | a11df2c963520c64768158c2753237152a1eae3d (patch) | |
tree | 2e96c294b0955680a76d4f1f95a1be297c9dcb0f /Semestr 4/ask/lista6/puzzle8.c | |
parent | 827657c21afae72288ff63254643a465682eb521 (diff) |
Update
Diffstat (limited to 'Semestr 4/ask/lista6/puzzle8.c')
-rw-r--r-- | Semestr 4/ask/lista6/puzzle8.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Semestr 4/ask/lista6/puzzle8.c b/Semestr 4/ask/lista6/puzzle8.c new file mode 100644 index 0000000..4d65f9d --- /dev/null +++ b/Semestr 4/ask/lista6/puzzle8.c @@ -0,0 +1,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; +}
\ No newline at end of file |