No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gnome_sort.b93 825B

1234567891011121314151617181920212223242526272829303132333435
  1. v
  2. ################################
  3. >>>v
  4. 012>v
  5. ^? 3v v+1 < <
  6. >0>: >??4> "0"+\2p1+:" "-#v_$ " "10p 0>:!#^_:10g-!#v_::1-2g\2g`!|
  7. ^ v? 5^ v ^p2\g02:-1p2\ g2-1::p02g2:<
  8. ^ 678>^ v $
  9. ^ >>>^ v @
  10. ^ v
  11. ^<<<<<<<<<<<<<<<<<<<<<<<<<<<
  12. [10] arr-size
  13. [20] tmp
  14. ---------------------------------------
  15. GNOME SORT
  16. ==========
  17. /// http://www.dickgrune.com/Programs/gnomesort.html
  18. void gnomesort(int n, int ar[])
  19. {
  20. int i = 0;
  21. while (i < n)
  22. {
  23. if (i == 0 || ar[i-1] <= ar[i]) i++;
  24. else {int tmp = ar[i]; ar[i] = ar[i-1]; ar[--i] = tmp;}
  25. }
  26. }