Guest User

Untitled

a guest
Mar 26th, 2020
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void ascending(stack &S){
  2. int pass, j, tmp;
  3.  
  4. for(pass = 1; pass <= Top(S); pass++){
  5. for (j = Top(S); j > 0; j--){
  6. if (info(S)[j] > info(S)[j-1]){
  7. tmp = info(S)[j];
  8. info(S)[j] = info(S)[j-1];
  9. info(S)[j-1] = tmp;
  10. }
  11. }
  12. }
  13. }
  14.  
  15. void descending(stack &S){
  16. int pass, j, tmp;
  17.  
  18. for(pass = 1; pass <= Top(S); pass++){
  19. for(j = Top(S); j > 1; j--){
  20. if(info(S)[j] < info(S)[j-1]){
  21. tmp = info(S)[j];
  22. info(S)[j] = info(S)[j-1];
  23. info(S)[j-1] = tmp;
  24. }
  25. }
  26. }
  27. }
RAW Paste Data