Backspace

Bjarki having trouble

Shortly before the programming contest started, Bjarki decided to update his computer. He didn’t notice anything strange until he started coding in his favorite editor, Bim (Bjarki IMproved). Usually when he’s writing in an editor and presses the backspace key a single character is erased to the left. But after the update pressing that key outputs the character <. He’s tested all the editors on his machine, Bmacs, Neobim, bjedit, NoteBjad++ and Subjark Text, but they all seem to have the same problem. He doesn’t have time to search the web for a solution, and instead decides to temporarily circumvent the issue with a simple program.

Help Bjarki write a program that takes as input the string that was written in the text editor, and outputs the string as Bjarki intended to write it. You can assume that Bjarki never intended to write the character <, and that Bjarki never pressed the backspace key in an empty line.

Input

One line containing the string that was written in the text editor. The length of the string is at most 106106, and it will only contain lowercase letters from the English alphabet as well as the character <.

Output

One line containing the string as Bjarki intended to write it.

Sample Input 1 Sample Output 1
a<bc<
b
Sample Input 2 Sample Output 2
foss<<rritun
forritun
Sample Input 3 Sample Output 3
a<a<a<aa<<

题意

遇到一个<就删除前一个字母,用栈来做,不过后来输出我还要用数组转换一下,不知道有什么能更方便点的方法

代码

#include<bits/stdc++.h>
using namespace std;
char aa[];
int main(){
stack<char> s;
string str;
cin>>str;
int len=str.size();
for(int i=;i<len;i++){
if(isalpha(str[i]))
s.push(str[i]);
else if(str[i]=='<')
s.pop();
}
int cnt=;
while(!s.empty()){
aa[cnt]=s.top();
s.pop();
cnt++;
}
for(int i=cnt-;i>=;i--){
cout<<aa[i];
}
cout<<endl;
return ;
}

Kattis -Backspace的更多相关文章

  1. Cygwin中解决vi编辑器方向键和Backspace键不好使、安装vim的方法

    修改.virc文件(如果没有就创建)vi .virc 添加以下内容set nocpset backspace=start,indent,eol 保存退出:wq 如果是vim就修改.vimrc文件. 由 ...

  2. 在网页中让Backspace按键不可作为退回使用

    这也是转载的,让BackSpace按键不可作为退回使用,在textbox中设置readonly时,将退回禁用. <script type="text/javascript"& ...

  3. 在IE下,如果在readonly的input里面键入backspace键,会触发history.back()

    在IE下,如果在readonly的input里面键入backspace键,会触发history.back(), 用以下jQuery代码修正之 $("input[readOnly]" ...

  4. js禁止Backspace键使浏览器后退

    在项目中遇到按下Backspace键让浏览器后退的问题,上网搜了几种解决方案都不太理想.于是集众人之智,采众家之长,归纳如下: 这里主要参考博客http://q821424508.iteye.com/ ...

  5. oracle 解决backspace和上下键使用出现乱码

    在bash提示符下,使用Del键或者Backspace键都能删除光标左右的字符,但是一旦进入sqlplus之后,只能使用Del键来删除光标左侧的字符,使用Backspace键则显示^H,使用ctrl+ ...

  6. securityCRT mongoDB 命令行删除(backspace/delete)无效问题

    1.MongoDB Shell中退格键使用的问题. 利用SecureCRT工具访问linux的时候,在使用MongoDB的交互式shell的时候,退格键(Backspace)无法使用,导致无法修改输入 ...

  7. IE下只读INPUT键入BACKSPACE 后退问题(readonly='true')

    在IE下,如果在readonly的input里面键入backspace键,会触发history.back(), 用以下jquery代码修正之 $("input[readOnly]" ...

  8. js禁用回退键backspace解决办法

    本文摘自http://q821424508.iteye.com/blog/1587025 以下为2.0版本,支持IE,firefox,chrome[这三款浏览器经过测试]等浏览器 window.onl ...

  9. JavaScript屏蔽Backspace键

    原文:http://www.cnblogs.com/xdp-gacl/p/3785806.html 今天在IE浏览器下发现,当把使用readonly="readonly"属性将文本 ...

随机推荐

  1. PAT-树的同构

    链接 树的同构 题意 同构的定义: 给定两棵树T1和T2.如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的. 给两棵树,判断是否同构 做法 先建树,然后判断,知道怎么判断就知道 ...

  2. C++基础 (3) 第三天 构造函数 构造函数初始化列表 拷贝构造函数 析构函数 静态成员变量

    // 同类之间无私处 2构造函数 3析构函数 4构造函数的种类和析构函数的顺序 结论:析构函数的调用顺序,跟对象的构造顺序相反,谁先构造,谁最后一个被析构. 拷贝构造函数: 注意: 等号写在下面和写在 ...

  3. 代码检查工具sonarqube介绍及使用

    亲测有效 环境:springboot+gradle+jdk1.8+sonarqube7.4 一.说明: SonarQube为静态代码检查工具,采用B/S架构,帮助检查代码缺陷,改善代码质量,提高开发速 ...

  4. element合并单元格方法及遇到问题的解决办法

    效果如图: 代码如下 <!-- 查看选课 --> <template> <div> <el-table :data="listData" ...

  5. P1546 最短网络 Agri-Net (kruskal)

    题目背景 农民约翰被选为他们镇的镇长!他其中一个竞选承诺就是在镇上建立起互联网,并连接到所有的农场.当然,他需要你的帮助. 题目描述 约翰已经给他的农场安排了一条高速的网络线路,他想把这条线路共享给其 ...

  6. Python编程:从入门到实践 - matplotlib篇 - Random Walk

    随机漫步 # random_walk.py 随机漫步 from random import choice class RandomWalk(): """一个生成随机漫步数 ...

  7. TFRecords转化和读取

    标准TensorFlow格式 TensorFlow的训练过程其实就是大量的数据在网络中不断流动的过程,而数据的来源在官方文档[^1](API r1.2)中介绍了三种方式,分别是: Feeding.通过 ...

  8. nodejs-循环

    for循环 for(var key in object){ consol.log('wor' : key); } 来自为知笔记(Wiz)

  9. Ajax-URL 防止数据缓存,添加时间戳

    url:CONTEXTPATH + "/dataService/getSourceStatics?type=0&t="+new Date().getTime(),

  10. ORACLE 參数文件介绍

    ORACLE数据库启动以后.通过select * from v$parameter这个语句能够查看到oracle数据库使用的全部參数. 对于oracle的參数文件,分为spfile 二进制文件和pfi ...