码迷,mamicode.com
首页 > 其他好文 > 详细

1000. List

时间:2016-10-22 15:01:10      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:namespace   name   while   out   front   for   begin   cout   cin   

#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();
    }
 }                                

1000. List

标签:namespace   name   while   out   front   for   begin   cout   cin   

原文地址:http://www.cnblogs.com/sysu-eeman-yang/p/5987382.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!