Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Input.
- let input = [3, 2, 5, 1];
- // Custom implementation of read and print. Do not touch : )
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- // Solution
- let num = +gets();
- let max = Number.MIN_SAFE_INTEGER;
- let min = Number.MAX_SAFE_INTEGER;
- let total = 0;
- for (i = 1; i <= num; i++) {
- let newValue = +gets();
- if (newValue >= max) {
- max = newValue;
- }
- if (newValue <= min) {
- min = newValue;
- }
- total += newValue;
- }
- print(`min=${min.toFixed(2)}`);
- print(`max=${max.toFixed(2)}`);
- print(`sum=${total.toFixed(2)}`);
- print(`avg=${(total / num).toFixed(2)}`);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement