#include <iostream>
#include 
<string>
#include 
<assert.h>
using namespace std;

typedef 
struct Linklist
{
    
int mDate;
    Linklist 
*pNext;
}
Node;

typedef 
struct myStack
{
    Node 
*top; 
}
myStack;

void Push(myStack *pStack, int date)
{
    Node 
*temp =  new Node;
    temp
->mDate = date;
    temp
->pNext = pStack->top;
    pStack
->top = temp;
}


int Pop(myStack *pStack)
{
    assert(pStack 
!= NULL);
    
int result = pStack->top->mDate;
    Node 
*temp = pStack->top;
    pStack
->top = pStack->top->pNext;
    delete temp;
    
return result;
}


//////////////////////////////////////////////////////

class newStack
{
public:
    newStack()
    
{
        top 
= -1;
        maxSize 
= 10;
        nums 
= new int[maxSize];
    }
;

    
~newStack()
    
{
        delete []nums;
    }


    
void Push(int mdate)
    
{
        assert(top 
< maxSize - 1);
        nums[top] 
= mdate;
        top
++;
    }


    
int pop()
    
{
        //assert(top 
> 0);
        
return nums[top--];
    }



private:
    
int *nums;
    
int maxSize;
    
int top;       
}
;


void main()
{
}
posted on 2009-06-09 15:36  Jackill  阅读(171)  评论(0编辑  收藏  举报