Broken Keyboard (a.k.a. Beiju Text)
来源:互联网 发布:算法类的书籍推荐 编辑:程序博客网 时间:2024/05/29 10:35
Description
Problem B
Broken Keyboard (a.k.a. Beiju Text)
You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem with the keyboard is that sometimes the "home" key or the "end" key gets automatically pressed (internally).
You're not aware of this issue, since you're focusing on the text and did not even turn on the monitor! After you finished typing, you can see a text on the screen (if you turn on the monitor).
In Chinese, we can call it Beiju. Your task is to find the Beiju text.
Input
There are several test cases. Each test case is a single line containing at least one and at most 100,000 letters, underscores and two special characters '[' and ']'. '[' means the "Home" key is pressed internally, and ']' means the "End" key is pressed internally. The input is terminated by end-of-file (EOF). The size of input file does not exceed 5MB.
Output
For each case, print the Beiju text on the screen.
Sample Input
This_is_a_[Beiju]_text[[]][][]Happy_Birthday_to_Tsinghua_University
Output for the Sample Input
BeijuThis_is_a__textHappy_Birthday_to_Tsinghua_University
Rujia Liu's Present 3: A Data Structure Contest Celebrating the 100th Anniversary of Tsinghua University
Special Thanks: Yiming Li
Note: Please make sure to test your program with the gift I/O files before submitting!
考虑到后面的【比总会前面的【使得,字符更加靠前,所以我就从右边考试需找【,找到就输出,左边的】在序列里没起作用,所以不用管,遇到直接输出!
#include<stdio.h>#include<string.h>char s[100008],z[100008];int main(){ while(scanf("%s",s)!=EOF) { int len=strlen(s),i,j; for(i=0;i<len;i++) { if(s[i]=='['||s[i]==']') z[i]='\0'; else z[i]=s[i]; } z[len]='\0'; for(j=len-1;j>=0;j--) { if(s[j]=='[') printf("%s",z+j+1); } if(!(s[0]=='['||s[0]==']')) printf("%s",z); for(j=0;j<len;j++) { if(s[j]==']') printf("%s",z+j+1); } printf("\n"); } return 0;}
- Broken Keyboard (a.k.a. Beiju Text)
- Broken Keyboard (a.k.a. Beiju Text)
- Broken Keyboard (a.k.a. Beiju Text)
- Broken Keyboard (a.k.a. Beiju Text)
- 11988 - Broken Keyboard (a.k.a. Beiju Text)
- Uva-11988-Broken Keyboard (a.k.a. Beiju Text)
- UVA 11988 Broken Keyboard (a.k.a. Beiju Text)
- uva 11988 Broken Keyboard (a.k.a. Beiju Text)
- UVA 11988 - Broken Keyboard (a.k.a. Beiju Text)
- UVA 11988 Broken Keyboard (a.k.a. Beiju Text)
- UVa11988-Broken Keyboard (a.k.a. Beiju Text)
- UVa:11988 Broken Keyboard (a.k.a. Beiju Text)
- UVA - 11988 Broken Keyboard (a.k.a. Beiju Text)
- uva11988 - Broken Keyboard (a.k.a. Beiju Text) 模拟 链表
- UVa11988 Broken Keyboard (a.k.a. Beiju Text)(链表 水)
- UVA 11988 Broken Keyboard (a.k.a. Beiju Text)
- UVa 11988 - Broken Keyboard (a.k.a. Beiju Text) 题解
- UVA 11988 - Broken Keyboard (a.k.a. Beiju Text)
- 编程之美
- 系统错误号:0x8007005
- 2013C++第六周任务-项目一(1)
- JNDI
- HDU 2206 - IP的计算
- Broken Keyboard (a.k.a. Beiju Text)
- 用于响应式设计的9个CSS技巧
- Boost.Lockfree官方文档翻译
- 猜拳小游戏
- 2013C++第六周任务-项目一(2)
- 黑马程序员-银行业务调度系统
- spring 中注解@Autowired,@Required,@Resource
- .net MVC3起步
- windbg命令分类与概述