CSU1019-Simple Line Editor-模拟
2017-06-26 00:02
399 查看
D: 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 m
a18d
istakenly 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 <bits/stdc++.h> #define N 10100 #define INF 0x3f3f3f3f #define LL long long #define mem(a,n) memset(a,n,sizeof(a)) #define fread freopen("in.txt","r",stdin) #define fwrite freopen("out.txt","w",stdout) using namespace std; int main() { ios::sync_with_stdio(false); int n,cnt; cin>>n; string temp,str; while(n--){ cin>>temp; str.resize(temp.size()); cnt=0; for(int i=0;i<temp.size();++i){ if(temp[i]=='#'){ if(cnt){ --cnt; } }else if(temp[i]=='@'){ cnt=0; }else{ str[cnt++]=temp[i]; } } for(int i=0;i<cnt;++i){ cout<<str[i]; } cout<<endl; } return 0; } /********************************************************************** Problem: 1019 User: CSUzick Language: C++ Result: AC Time:0 ms Memory:1688 kb **********************************************************************/
相关文章推荐
- CSU 1019: Simple Line Editor(模拟)
- WA : csu1019 simple line editor
- csu 1019 Simple Line Editor
- CSU---D: Simple Line Editor
- COJ-1019-Simple Line Editor
- Simple Line Editor
- Simple Line Editor----CSU 1019
- Simple Line Editor
- Simple Line Editor
- ACM: Simple Line Editor
- Simple Line Editor Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 250(49 users) Total Accepted: 74(42 users) Special Judge: No Description
- 哈理工 oj——Simple Line Editor
- Expression parameters.formName is undefined on line 120, column 43 in template/simple/doubleselect.ftl
- CSU1312:榜单(模拟)
- CSU - 1850 Grade School Multiplication 模拟乘法竖式
- CSU1329 一行盒子(模拟链表)
- CSU1730-Tractatus Logico-Philosophicus(模拟)
- CSU-ACM2017暑期训练5-三分 E - Line belt HDU - 3400
- csu1779——错误的算法(模拟)
- NYOJ 413 && POJ 1019 Number Sequence(模拟)