Facebook
From Paltry Tortoise, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 217
  1. void changeOrder(ele *&stack1, elem *&stack2){
  2.     int r = 0;
  3.     int elems = 0;
  4.     int stack1Size = size(stack1) - 1;
  5.     while(stack1Size != 0)
  6.     {
  7.         int r = pop(stack1);
  8.         elems = stack1Size;
  9.         while(elems-- > 0){
  10.             push(stack2, pop(stack1));
  11.         }
  12.         push(stack1, r);
  13.         while(stack2 != nullptr){
  14.             push(stack1, pop(stack2));
  15.         }
  16.         stack1Size--;
  17.     }
  18. }