Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 10th, 2012  |  syntax: Java  |  size: 0.53 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public void sortieren(Stapel x){
  2.     Stapel s1 = new Stapel();
  3.     Stapel s2 = new Stapel();
  4.     while(!x.isEmpty()){
  5.       if(!s2.isEmpty()){
  6.         if(s2.top()>=x.top()){
  7.           s2.push(x.top());
  8.           x.pop();
  9.           while(!s1.isEmpty(){
  10.             s2.push(s1.top());
  11.             s1.pop();
  12.           }
  13.         }
  14.         else{
  15.           s1.push(s2.top());
  16.           s2.pop();
  17.         }
  18.       }
  19.       else{
  20.         s2.push(x.top());
  21.         x.pop();
  22.         while(!s1.isEmpty(){
  23.           s2.push(s1.top());
  24.           s1.pop();
  25.         }
  26.       }
  27.     }
  28.     x = s1;
  29.   }