栈&队列
2024-07-25 16:20:03
发布于:北京
栈
#include<bits/stdc++.h>
using namespace std;
int s[110];
int top;
//推进元素
void push(int x){
s[++top]=x;
}
//去顶元素
void pop(){
top--;}
//清空栈
bool empty(){
return top==0;
}
int main() {
return 0;
}
队列
#include<bits/stdc++.h>
using namespace std;
int s[110];
int top;
//推进元素
void push(int x){
q[tail++]=x;
}
//读顶元素
int front(){
return q[head];}
//清空队列
bool empty(){
return head==tail;
}
//读取队列长度
int size(){
return tail-head;}
//读尾元素
int back(){
return q[tail-1];}
void pop(){
head++;
}
int main() {
return 0;
}
全部评论 1
👍👍👍👍👍
2024-07-25 来自 北京
0
有帮助,赞一个