# UVa 11988 - Broken Keyboard (a.k.a. Beiju Text)
---
# 題目大意
有個壞掉的鍵盤會不時按下”Home”鍵與"End"鍵。本題給定鍵盤輸出的字串(包含Home與End),要求輸出該字串顯示的內容。
---
# 題解
用deque模擬插入字串
---
```=C++
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define ft first
#define sec second
#define pr pair<int,int>
#define ISCC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const ll MOD = 1e9+7;
int t ,n ,m ,ok ,now;
string s;
int main()
{
int now=0;
while(getline(cin,s))
{
deque<string> dqu;
string tp = ""; now = 1;
for(int i=0 ;i<s.size() ;i++)
{
if(s[i]=='[' || s[i]==']')
{
if(now) dqu.pb(tp);
else dqu.push_front(tp);
now = (s[i]==']'); tp = "";
}
else tp += s[i];
}
if(now) dqu.pb(tp);
else dqu.push_front(tp);
for(auto v : dqu) cout << v; cout << '\n';
}
return 0;
}
```