Stacks & Queues by TinTin20th Feb 2007 7:59
|
---|
Summary How to use Stacks & Queues Description Simple demonstration on using Stacks and Queues Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `Stacks & Queues Dim ST():Empty Array ST() Dim QU():Empty Array QU() For I=0 to 2 `Add To Arrays J=RND(10)+5 For I=0 to J Add to Stack ST(): ST()=I Add to Queue QU(): QU()=I Next `Sub From Arrays J=RND(J/2)+3 For I=0 to J Remove from Stack ST() Remove from Queue QU() Next Next `Print Arrays If Array Count(ST())>0 Print "Stack "; For I=0 to Array Count(ST()) Print ST(I);" "; Next Print " LIFO " EndIf If Array Count(QU())>0 Print "Queue "; For I=0 to Array Count(QU()) Print QU(I);" "; Next Print " FIFO " EndIf `Clearup Empty Array ST() Empty Array QU() Do:Loop End |