栈与队列

#include<cstdio>
#include<stack>
using namespace std;
int main()
{
    stack<int> s;
    s.push(1);
    s.push(2);
    s.push(3);
    printf("%d\n",s.top());//是输出,但是这个数还在
    s.pop();//弹出,数不在栈里面
    printf("%d\n",s.top());
    s.pop();
    printf("%d\n",s.top());
    s.pop();
    return 0;
}
#include<cstdio>
#include<queue>
using namespace std;
int main()
{
    queue<int> que;
    que.push(1);
    que.push(2);
    que.push(3);
    printf("%d\n",que.front());//输出是front
    que.pop();
    printf("%d\n",que.front());
    que.pop();
    printf("%d\n",que.front());
    que.pop();
    return 0;
   
}

这些应该是最简单的吧,难的应该还是不会

 

posted @ 2016-07-18 17:04  小小姐  阅读(128)  评论(0编辑  收藏  举报