破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988)

题意描述

你在输入文章的时候,键盘上的Home键和End键出了问题,会不定时的按下。你却不知道此问题,而是专心致志地打稿子,甚至显示器都没开。当你打开显示器之后,展现你面前的数一段悲剧文本。你的任务是在显示器打开前计算出这段悲剧的文本。 给你一段按键的文本,其中'['表示Home键,']'表示End键,输入结束标志是文件结束符(EOF)。

样例输入

This_is_a_[Beiju]_text

[[]][][]Happy_Birthday_to_Tsinghua_University

样例输出

BeijuThis_is_a__text

Happy_Birthday_to_Tsinghua_University

实现

#include<bits/stdc++.h>
using namespace std;
int main(){
string line;
while(getline(cin,line)){
deque<string> result;
string str;
int flag=1;//flag=1 push_back,flag=0 push_front
for(int i=0;i<line.length();i++){
if(line[i] == '['){flag=0;}
else if(line[i] == ']'){
if(!str.empty()){
result.push_front(str);
str.clear();
}
flag=1;}
else{//normal c or _
if(flag){
string s;
s.push_back(line[i]);
result.push_back(s);
}
else {
str=str+line[i];
}
}
}
deque<string>::iterator it;
for(it=result.begin();it!=result.end();++it){
cout<<*it;
}
cout<<endl;
}
}

破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988)的更多相关文章

  1. Broken Keyboard (a.k.a. Beiju Text) UVA - 11988

    You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem wi ...

  2. Broken Keyboard (a.k.a. Beiju Text) UVA - 11988 (链表)

    题目链接:https://vjudge.net/problem/UVA-11988 题目大意:输入一个字符串,输出在原本应该是怎么样的?  具体方法是 碰到' [ ' 回到最前面  碰到‘ ]’  回 ...

  3. B - Broken Keyboard (a.k.a. Beiju Text)

    Problem B Broken Keyboard (a.k.a. Beiju Text) You're typing a long text with a broken keyboard. Well ...

  4. uva - Broken Keyboard (a.k.a. Beiju Text)(链表)

    11988 - Broken Keyboard (a.k.a. Beiju Text) You’re typing a long text with a broken keyboard. Well i ...

  5. N - Broken Keyboard (a.k.a. Beiju Text)(DFS,链表)

    N - Broken Keyboard (a.k.a. Beiju Text) Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:% ...

  6. UVA——11988 Broken Keyboard (a.k.a. Beiju Text)

    11988 Broken Keyboard (a.k.a. Beiju Text)You’re typing a long text with a broken keyboard. Well it’s ...

  7. B - Broken Keyboard (a.k.a. Beiju Text) 数组模拟链表

    You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem wi ...

  8. UVa 11988 - Broken Keyboard (a.k.a. Beiju Text) 题解

    刘汝佳的题目,悲剧文本 -_-||| 这里使用vector<string>容器倒置记录数据,然后从后面输出就能够了. 难度就是不知道这种文档究竟哪里是開始输出,故此使用动态管理内存的容器比 ...

  9. Broken Keyboard (a.k.a. Beiju Text) 思路

    问题:You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problem ...

随机推荐

  1. AngularJs 延时器、计时器

    1.$timeout延时器 apptest.controller("main",function($scope,$timeout){ $scope.pink="pink& ...

  2. vue中数组删除,页面没重新渲染

    创建一个组件时,数据类型是数组,在删除这个数组中的数据时,数组中的数据是对的,但页面渲染的数据却不对. 举例:(不一定复现) <ul> <li v-for="(item, ...

  3. hdu 2063 过山车(模板)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2063 过山车 Time Limit: 1000/1000 MS (Java/Others)    Me ...

  4. Mac系统丢失管理员

    今天把osx变成平行用户,提示说要重启,但是一进来,我靠,自己的管理员用户变成了普通用户.我靠,有这么搞的嘛? 不能安装软件,不能https,不能保存密码,什么也不能做了. 网上一查,找到了几个解决方 ...

  5. SQL点点滴滴_修改数据库的兼容级别

    语法 ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = { 80 | 90 | 100 } 参数 database_name 要修改的数据库 ...

  6. tcp.cc

    ns2-tcp-tcp.cc /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ /* * Copyri ...

  7. SQLSERVER procedure 传入参数为DataTable类型 C#该怎么写

    以上为数据库中存储过程传入参数为table类型 table类型在数据库中存在为: 最后在C#实现方式为:

  8. 【Leetcode】【Medium】Search for a Range

    Given a sorted array of integers, find the starting and ending position of a given target value. You ...

  9. python功能代码块记录

    python Autopep8——按PEP8风格自动排版Python代码(参考链接) autopep8 --in-place --aggressive --aggressive test_autope ...

  10. 08提权 系统文件权限和远程连接IP绕过 安装后门

    大家都知道08权限的系统权限设置很严格  面对限制IP连接的情况 我们及时拿到system权限 有账号也上不去这种情况下只能弄shift后门 或者放大镜了  但08权限 在system权限也操作不了系 ...