栈操作的模拟代码(数组)
2023-08-04 22:59:19
发布于:上海
#include<bits/stdc++.h>
using namespace std;
int st[1001],top;
void push(int x){ st[++top]=x; } //将x数据压栈
void pop(){ top--; } //弹出栈顶元素
int Top(){ return st[top]; } //输出栈顶元素
bool empty(){ return top==0; } //返回栈是否为空
int size(){ return top; } //返回栈大小
void clean(){ top = 0; } //将栈清空
void out(){ while(! empty()){ cout<<Top(); pop(); } } //输出基本出栈顺序排列
int main(){
}
这里空空如也
有帮助,赞一个