def reverse_order(S):
    stk3=stack.LimitedStack()
    stk4=stack.LimitedStack()
    while S.isempty()==False:
        w=S.pop()
        stk3.push(w)
    while stk3.isempty()==False:
        y=stk3.pop()
        stk4.push(y)
    while stk4.isempty()==False:
        z=stk4.pop()
        S.push(z)
import stack
if __name__ == '__main__':
    R=stack.LimitedStack()
    S=stack.LimitedStack()
    T=stack.LimitedStack()
    temp1=stack.LimitedStack()
    temp2=stack.LimitedStack()
    R.push(1)
    R.push(2)
    R.push(3)
    S.push(4)
    S.push(5)
    T.push(6)
    T.push(7)
    T.push(8)
    T.push(9)
    while S.isempty()==False:
        h=S.pop()
        temp1.push(h)
    while T.isempty()==False:
        j=T.pop()
        temp1.push(j)
    while temp1.isempty()==False:
        n=temp1.pop()
        S.push(n)
    while temp2.isempty()==False:
        k=temp2.pop()
        S.push(k)
    print("R is", R.data)
    print("S is", S.data)
import stack


def reverse(s, t):
    while s.isempty() == False:
        w = s.pop()
        t.push(w)


if __name__ == '__main__':
    stk1 = stack.LimitedStack()
    stk1.push(10)
    stk1.push(20)
    stk1.push(30)
    stk1.push(40)
    stk1.push(50)
    stk1.push(60)
    stk1.push(70)
    stk1.push(80)
    stk1.push(90)
    stk1.push(100)
    stk2 = stack.LimitedStack()
    reverse(stk1, stk2)
    print("the reveresed list is", stk2.data)
Beispiel #4
0
def test_emptystack():
    stk = stack.LimitedStack()
    assert (stk.isempty())
    assert (stk.length() == 0)