当前位置:网站首页>数组模拟栈

数组模拟栈

2022-06-22 16:58:00 安德伍德之心

#include <iostream>
using namespace std;

const int N = 100010;

int stk[N], tt;

//插入
void push(int x)
{
    
	stk[++tt] = x;
}

//弹出
void pop()
{
    
	tt--;
}

//判断栈是否为空
bool isEmpty()
{
    
	if(tt>0) return false;
	else return true;
}

//获得栈顶,不弹出 
int pop()
{
    
	return skt[tt];
} 
原网站

版权声明
本文为[安德伍德之心]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45979976/article/details/125333223