deque

#include <deque>
#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;
typedef long long ll;
deque < ll > d;
inline ll read () {
    ll x=0,f=1;
    char ch=getchar();
    while(!isdigit(ch)) {
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(isdigit(ch)) {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
int n;
signed main() {
    n=read();
    for(register int i=1; i<=n; i++) d.push_back(read());
    for(deque< ll >::iterator it=d.begin(); it!=d.end(); it++) {
        cout<<d.front()<<' ';// d.back()
        d.pop_front();
    }
//与vector相似 push_back
//从头部插入元素,不会增加新元素,只将原来有的元素覆盖 push_front()
//删除元素 可以从双端队列的手部,尾部,中部删除元素,并可以清空双端队列容器
//d.empty()队列是否是空的
//d.size()元素个数
//d.clear() 清空队列
//d.pop_front() 清空队首的第一个元素
//d.pop_back() 清空队尾的第一个元素
    return 0;
}

 

posted @ 2019-01-31 12:05  Isaunoya  阅读(110)  评论(0编辑  收藏  举报
TOP