CSU 1019: Simple Line Editor(模拟)
来源:互联网 发布:ubuntu gcc离线安装包 编辑:程序博客网 时间:2024/05/29 10:07
CSU 1019: 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 ‘#’.
there are no more than 1000 letters for each test case.
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
2ab#aab@aa
Sample Output
aaaa
Hint
Source
中南大学第四届大学生程序设计竞赛
思路: 模拟
#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <queue>#include <map>#include <algorithm>using namespace std;int N;string s;string tmp;int i;int ti;int main(){ scanf("%d",&N); while(N--) { cin>>s; tmp.clear(); for(int j = s.length() - 1 ; j >= 0 ; j--) { if(s[j] == '@') s = s.substr(j+1,s.length() - j); } for(i = 0 ; i < s.length() ; i++) { if(s[i] == '#') { if(tmp.empty()) continue; else { tmp = tmp.substr(0,tmp.length() - 1); } } else { tmp += s[i]; } } cout<<tmp<<endl; } return 0;}
- CSU 1019: Simple Line Editor(模拟)
- Simple Line Editor----CSU 1019
- CSU---D: Simple Line Editor
- CSU1019-Simple Line Editor-模拟
- COJ-1019-Simple Line Editor
- Simple Line Editor
- Simple Line Editor
- Simple Line Editor
- ACM: Simple Line Editor
- 哈理工 oj——Simple Line Editor
- Simple Editor
- csu 1550: Simple String (字符串)
- CSU 1550-Simple String(字符串)
- simple i18n editor
- CSU 1202 Stone-scissors-cloth (模拟)
- CSU 1203 Super-increasing sequence (模拟)
- csu oj 1031 Real Numbers(模拟)
- CSU 1267: Operation(模拟啊 )
- HDU6129-Just do it
- nginx(2) 配置站点示例
- Android EventBus源码解析 带你深入理解EventBus
- python实现简单redis客户端(1)
- 2017.8.16 pyton实现登录界面
- CSU 1019: Simple Line Editor(模拟)
- 创建UDF的简单方法介绍
- java高并发
- Swift宏定义
- html+jquery实现字幕滚动公告
- Memcache的详细讲解
- 移动web 1像素边框
- Java序列化和文件的输入/输出
- java高并发