You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problem with the keyboard is that sometimes the “home” key or the “end” key gets automatically pressed

(internally).

You’re not aware of this issue, since you’re focusing on the text and did not even turn on the monitor! After you finished typing, you can see a text on the screen (if you turn on the monitor). In Chinese, we can call it Beiju. Your task is to find the Beiju text.

Input

There are several test cases. Each test case is a single line containing at least one and at most 100,000 letters, underscores and two special characters ‘[’ and ‘]’. ‘[’ means the “Home” key is pressed internally, and ‘]’ means the “End” key is pressed internally. The input is terminated by end-of-file (EOF).

Output

For each case, print the Beiju text on the screen.

Sample Input

This_is_a_[Beiju]_text
[[]][][]Happy_Birthday_to_Tsinghua_University

Sample Output

BeijuThis_is_a__text
Happy_Birthday_to_Tsinghua_University

HINT

字符'['将链表指针置于头,字符’]‘将链表指针置于尾部。插入字符用insert(pos,var);第一个参数是一个指针,指向要插入的地址前面,后面的是要插入的值。返回插入的地址。

Accepted

#include<bits/stdc++.h>
using namespace std; int main(){
string s;
while (getline(cin, s) && s.length()) {
list<char>L;
auto p = L.begin();
for (int i = 0;i < s.length();i++) {
if (s[i] == '[')p = L.begin();
else if (s[i] == ']')p = L.end();
else {
p=L.insert(p, s[i]);
p++;
}
}
for (p = L.begin();p != L.end();p++)cout << *p;
cout << endl;
}
}

最新文章

  1. 纯前端JSON文件编辑器[0]
  2. MarkDown常用语法记录
  3. vm centos 网络配置
  4. web前端开发教程系列-2 - 前端开发书籍分享(转)
  5. 关于android中Bundle的使用
  6. [转自老马的文章]用MODI OCR 21种语言
  7. 20145218 《Java程序设计》第02次实验报告
  8. NOR Flash擦写和原理分析 (二)
  9. 【LR】版本问题
  10. 制作ado开发辅助工具类SqlHelper
  11. MVC4.0系统开发新手历程(二)
  12. sass基础—继承及占位符
  13. python文件、文件夹的移动、复制、删除、重命名
  14. Nginx http反向代理流程Proxy_pass模块
  15. wave
  16. form表单公用
  17. C++ 函数模板重载
  18. 电影《Green book》观后感_已补全:携带着种族歧视的“光环”,艰难地获得朋友的相互依赖,依然得享受生活的酸甜苦咸。
  19. Goroutines和Channels(二)
  20. 自定义ProgressBar的加载效果

热门文章

  1. java与freemarker遍历map
  2. redis.conf 配置说明
  3. CSS过渡约束的计算
  4. OpenGL中的简单坐标系初看+VAO/VBO/EBO
  5. WEBAPI 的调用方式
  6. Python3.x 基础练习题100例(81-90)
  7. CMU数据库(15-445)Lab3- QUERY EXECUTION
  8. 写个锤子JS!它应该是你最后的选择
  9. P3160 [CQOI2012]局部极小值 题解(状压DP+容斥)
  10. Harry And Magic Box HDU - 5155