Advertisement
Zhorzh

Untitled

Nov 22nd, 2021
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. function solve(args) {
  2. let n = Number(args[0])
  3. let max1 = Number.NEGATIVE_INFINITY
  4. let max2 = Number.NEGATIVE_INFINITY
  5. let max3 = Number.NEGATIVE_INFINITY
  6. for (let i = 1; i <= n; i++) {
  7. let currNum = Number(args[i])
  8. if (currNum > max1) {
  9. max1 = currNum
  10. }
  11. for (let j = 1; j <= n; j++) {
  12. let currNum1 = Number(args[j])
  13. if (currNum1 > max2 && currNum1<currNum) {
  14. max2 = currNum1
  15. }
  16. for (let k = 1; k <= n; k++) {
  17. let curNum2 = Number(args[k])
  18. if (curNum2 > max3 && curNum2 < max2) {
  19. max3 = curNum2
  20. }
  21. }
  22. }
  23. }
  24. console.log(max1 + ', ' + max2 + ' and ' + max3)
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement