
Untitled
By: a guest on
Jun 10th, 2012 | syntax:
Java | size: 0.53 KB | hits: 22 | expires: Never
public void sortieren(Stapel x){
Stapel s1 = new Stapel();
Stapel s2 = new Stapel();
while(!x.isEmpty()){
if(!s2.isEmpty()){
if(s2.top()>=x.top()){
s2.push(x.top());
x.pop();
while(!s1.isEmpty(){
s2.push(s1.top());
s1.pop();
}
}
else{
s1.push(s2.top());
s2.pop();
}
}
else{
s2.push(x.top());
x.pop();
while(!s1.isEmpty(){
s2.push(s1.top());
s1.pop();
}
}
}
x = s1;
}