#include <iostream>
#include <list>

using namespace std;

int main()
{
    int n;
    while(cin >> n) {
        list <int> num;
        while(n--) {
            string s;
            cin >> s;
            if(s == "push_back") {
                int a;
                cin >> a;
                num.push_back(a);
            } else if(s == "push_front") {
                int b;
                cin >> b;
                num.push_front(b);
            } else if(s == "pop_back") {
                num.pop_back();
            } else if(s == "pop_front") {
                num.pop_front();
            } else if(s == "print") {
                cout << "List:" << endl;
                for(list<int>::iterator it = num.begin(); it != num.end(); it++) {
                    cout << *it << endl;
                }
            }
        }
        num.clear();
    }
 }                                

posted on 2016-10-22 13:13  任我主宰  阅读(112)  评论(0编辑  收藏  举报