Guest User

Untitled

a guest
Mar 17th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. const ascArr = (x = []) => {
  2. const big_r = x.length
  3. let small_r = x.length
  4. let buff
  5. let round = 1
  6.  
  7. const max = Math.max(...x)
  8. const min = Math.min(...x)
  9.  
  10. for (ii = 0; ii <= big_r - 2; ii++) {
  11. console.log(ii + 1)
  12. for (i = 0; i <= small_r - 2; i++) {
  13. if (x[i] > x[i + 1]) {
  14. buff = x[i]
  15. x[i] = x[i + 1]
  16. x[i + 1] = buff
  17. }
  18. console.log("Round : " + round + " => " + x)
  19. round++
  20. }
  21. small_r = small_r - 1
  22. }
  23.  
  24. round = round - 1
  25.  
  26. console.log("Member of array : " + big_r)
  27. console.log("Round : " + round)
  28. }
  29.  
  30. //ascArr([90, 81, 30, 45, 35, 56, 15, 2, 7, 23, 11, 33])
  31. ascArr([90, 81, 56, 45, 35, 33, 30, 23, 15, 11, 7, 2])
  32. //ascArr([90, 81, 30, 45, 35, 56, 15, 2, 7, 23, 11])
Add Comment
Please, Sign In to add comment