Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let n = +gets() //4
- let max;
- let min;
- let sum = 0;
- let avg = 0;
- for (let i = 1; i <= n; i++) {
- let next = +gets()
- let current = next
- sum = sum + next
- if (i === 1) {
- max = current
- min = current
- }
- if (current > max) {
- max = current
- }
- else if (current < min) {
- min = current
- }
- }
- avg = sum / n;
- print(`Min = ${min.toFixed(2)}`)
- print(`Max = ${max.toFixed(2)}`)
- print(`Sum = ${sum.toFixed(2)}`)
- print(`Avg = ${avg.toFixed(2)}`)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement