Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ascArr = (x = []) => {
- const big_r = x.length
- let small_r = x.length
- let buff
- let round = 1
- const max = Math.max(...x)
- const min = Math.min(...x)
- for (ii = 0; ii <= big_r - 2; ii++) {
- console.log(ii + 1)
- for (i = 0; i <= small_r - 2; i++) {
- if (x[i] > x[i + 1]) {
- buff = x[i]
- x[i] = x[i + 1]
- x[i + 1] = buff
- }
- console.log("Round : " + round + " => " + x)
- round++
- }
- small_r = small_r - 1
- }
- round = round - 1
- console.log("Member of array : " + big_r)
- console.log("Round : " + round)
- }
- //ascArr([90, 81, 30, 45, 35, 56, 15, 2, 7, 23, 11, 33])
- ascArr([90, 81, 56, 45, 35, 33, 30, 23, 15, 11, 7, 2])
- //ascArr([90, 81, 30, 45, 35, 56, 15, 2, 7, 23, 11])
Add Comment
Please, Sign In to add comment