Simple Line Editor
来源:互联网 发布:运动鞋女跑步鞋淘宝 编辑:程序博客网 时间:2024/06/08 18:46
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
2ab#aab@aa
Sample Output
aaaa解题报告:这类字符匹配题目都可以用栈来做。比如括号匹配。code:#include<iostream>#include<algorithm>#include<stdio.h>#include<queue>#include<stack>#include<math.h>#include<string.h>using namespace std;typedef long long ll;int main(){ // freopen("input.txt","r",stdin); int t; char s[1000]; scanf("%d",&t); getchar(); while(t--){ scanf("%s",s); stack<char> st; int len=strlen(s); for(int i=0;i<len;i++){ if(s[i]=='#'&&!st.empty()) st.pop(); else if(s[i]=='@') while(!st.empty()) st.pop(); else st.push(s[i]); } char ch[1000]; int i=0; while(!st.empty()){ ch[i++]=st.top(); st.pop(); } ch[i]='\0'; for(int j=i-1;j>=0;j--) printf("%c",ch[j]); printf("\n"); } return 0;}
- Simple Line Editor
- Simple Line Editor
- Simple Line Editor
- ACM: 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
- 为Eclipse写插件-----Simple Editor
- increase line spacing with vi editor
- simple line chart , scatter diagram and RandomWalk
- Leetcode 8. String to Integer (atoi)
- 添加RichEdit控件导致MFC对话框程序无法执行的解决方法
- 51Nod-1103-N的倍数
- 图解Oracle用户管理
- 第九轮回 没有卵用的寻求帮助
- Simple Line Editor
- c++四种强制类型转化的区别
- 网站排名的基本原则
- Activity launchMode详解
- HDU 5519(Kykneion asma-NNT+CRT)
- 二维数组翻转
- Python Markdown的使用
- jsp链接数据库
- Linux中文显示设置