码迷,mamicode.com
首页 > 其他好文 > 详细

栈的模板

时间:2018-02-19 10:23:14      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:std   str   ++   include   pre   int   names   end   bool   

#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;
}

 

栈的模板

标签:std   str   ++   include   pre   int   names   end   bool   

原文地址:https://www.cnblogs.com/incotnigo/p/8453419.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!