arrayA=[None for index in range (0,9)] arrayB=[] toppointerA=-1 stackfullA=10 def push(num): global toppointerA,stackfullA if toppointerA>=stackfullA-1: print("you have problem") else: toppointerA =toppointerA+1 arrayA[toppointerA]=num def pop(): global toppointerA, stackfullA if toppointerA<0: print("this is empty") else: arrayA[toppointerA-stackfullA-1]=None stackfullA=stackfullA-1 push(3) push(4) push(5) pop() pop() print(arrayA)
Show how to implement a queue using two stacks.
最新推荐文章于 2024-07-12 19:06:42 发布