ACM: Simple Line Editor
来源:互联网 发布:深入php内核 编辑:程序博客网 时间:2024/06/09 14:15
Simple Line Editor
Description
Early computer used line editor, which allowed text to be created and changed only within one line at a time. However, in line editor programs, typing, editing, and document display do not occur simultaneously (unlike the modern text editor like Microsoft Word). Typically, typing does not enter text directly into the document. Instead, users modify the document text by entering simple commands on a text-only terminal.
Here is an example of a simple line editor which can only process English. In addition, it has two commands. ‘@’ and ‘#’. ‘#’ means to cancel the previous letter, and ‘@’ is a command which invalidates all the letters typed before. That is to say, if you want type “aa”, but have mistakenly entered “ab”, then you should enter ‘#a’ or ‘@aa’ to correct it. Note that if there is no letter in the current document, ‘@’ or ‘#’ command will do nothing.
Input
The first line contains an integer T, which is the number of test cases. Each test case is a typing sequence of a line editor, which contains only lower case letters, ‘@’ and ‘#’.
Output
For each test case, print one line which represents the final document of the user. There would be no empty line in the test data.
Sample Input
2
ab#a
ab@aa
Sample Output
aa
aa
#include <iostream>#include <cstdio>#include <cstring>#include <vector>#include <cmath>#include <algorithm>#include <string>using namespace std;int main(){int n;string str;cin>>n;
while(n--){
cin>>str;
int len=str.size();string newstr;//memset(newstr,0,sizeof(newstr));int j=0;for(int i=0;i<len;i++){
if(str[i]=='#'){
j--;
}
else if(str[i]=='@'){
j=0;}
else{
newstr[j++]=str[i];
}
}
for(int i=0;i<j;i++)cout<<newstr[i];
cout<<endl;
}
return 0;}
- ACM: Simple Line Editor
- Simple Line Editor
- Simple Line Editor
- Simple Line Editor
- Simple Line Editor----CSU 1019
- COJ-1019-Simple Line Editor
- CSU---D: Simple Line Editor
- CSU1019-Simple Line Editor-模拟
- CSU 1019: Simple Line Editor(模拟)
- 哈理工 oj——Simple Line Editor
- Simple Editor
- simple i18n editor
- C++ HackerRank|Simple Text Editor
- On-Line Rich Text Editor.
- simple introduction for pipe line
- ACM题-simple equation
- 为Eclipse写插件-----Simple Editor
- increase line spacing with vi editor
- Java配置环境变量
- [openstack]NFVI特性之实时虚拟机(二)
- MYSQL 优化原理
- delta coding入门
- Python实现文件拷贝和解开权限
- ACM: Simple Line Editor
- Linux环境进程间通信
- 冒泡排序法(BubbleSort)的改进以及效率比较
- logistic回归详解二:损失函数
- kafka总结
- c# datatable数据合并方法
- mysql的模糊查询以及时间类型整理
- javascript的面向对象详解
- Mathtype复制到word中行距变大问题解决方案