栈的模板

#include<iostream>
using namespace std;
//
void push(int x);
int pop();
bool isEmpty();
bool isFull();
//
int A[5010],top=0;


int main()
{
    push(50);
    cout<<pop()<<endl;
    cout<<top;
}


void push(int x)
{
    if(isFull)
    {
    A[top]=x;
    top++;
    }
}

int pop()
{
    if(isEmpty)
    {
    top--;
    return A[top];
    }
}

bool isEmpty()
{
    if(A[top]==0) return 0;
    else return 1;
}

bool isFull()
{
    if(top==5000) return 0;
    else return 1;
}

 

posted @ 2018-02-19 00:49  incotnigo  阅读(117)  评论(0)    收藏  举报