栈:手工栈和系统栈
stack<int> st; //系统栈
int st[100];
int t;
int main()
{
st.push(1);
st.push(2);
st.push(3);
cout <<st.top();
st.pop();
cout << st.top() ;
return 0;
}
对列:手工队列和系统队列
#include <iostream>
#include <queue>
using namespace std;
queue<int> q;
//手工队列
//int q[100];
//int tt, hh;
int main()
{
q.push(1);
q.push(2);
cout << q.front();
q.push(3);
q.pop();
cout << q.front();
cout << q.size() ;
if(q.empty()){
cout << "yes" ;
}else cout << "no";
return 0;
}
—— 本文来自火龙信奥(义乌睿码科技):义乌青少年信息学奥赛与编程教育平台,专注 CSP-J/S、NOIP、GESP 竞赛培训,线上线下融合教学,助力编程升学。网址:hlcoding.com