悲剧文本(Broken Keyboard (a.k.a. Beiju Text),UVA 11988)
题目描述:

题目思路:
1.使用链表来重新定位各个字符
2.用数组实现链表
3.开一个数组list[i]来存储字符数组下一个字符的位置
#include <iostream>
#include <cstring>
using namespace std; const int maxn = + ;
int last,cur,list[maxn] ;
char s[maxn] ;
int main(int argc, char *argv[])
{
while(scanf("%s",s+) == )
{
int len = strlen(s+);
last = cur = ;
list[] = ; //指示位置的链表 for(int i = ;i <= len ;i++)
{
char ch = s[i] ;
if(ch == '[') cur = ;
else if(ch == ']') cur = last ;
else{
list[i] = list[cur] ; //光标跳转,指示开头
list[cur] = i;
if(cur == last) last = i ;
cur = i ;
}
}
for(int i = list[]; i != ;i = list[i])
printf("%c",s[i]);
cout << endl ;
}
return ;
}
悲剧文本(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) 题意描述 你在输入文章的时候,键盘上的Home键和End键出了问题,会不定时的按下. ...
- Broken Keyboard (a.k.a. Beiju Text) UVA - 11988
You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem wi ...
- Broken Keyboard (a.k.a. Beiju Text) UVA - 11988 (链表)
题目链接:https://vjudge.net/problem/UVA-11988 题目大意:输入一个字符串,输出在原本应该是怎么样的? 具体方法是 碰到' [ ' 回到最前面 碰到‘ ]’ 回 ...
- B - Broken Keyboard (a.k.a. Beiju Text)
Problem B Broken Keyboard (a.k.a. Beiju Text) You're typing a long text with a broken keyboard. Well ...
- uva - Broken Keyboard (a.k.a. Beiju Text)(链表)
11988 - Broken Keyboard (a.k.a. Beiju Text) You’re typing a long text with a broken keyboard. Well i ...
- N - Broken Keyboard (a.k.a. Beiju Text)(DFS,链表)
N - Broken Keyboard (a.k.a. Beiju Text) Time Limit:1000MS Memory Limit:0KB 64bit IO Format:% ...
- UVA——11988 Broken Keyboard (a.k.a. Beiju Text)
11988 Broken Keyboard (a.k.a. Beiju Text)You’re typing a long text with a broken keyboard. Well it’s ...
- 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 ...
- 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 wi ...
- UVa 11988 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 wi ...
随机推荐
- linux常用监测命令
1 uptime uptime 命令可以用来查看服务器已经运行了多久,当前登录的用户有多少. 2 top top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于W ...
- NodeJs——入门
关于NPM: npm 是 nodejs 的包管理和分发工具.它可以让 javascript 开发者能够更加轻松的共享代码和共用代码片段,并且通过 npm 管理你分享的代码也很方便快捷和简单. 一 No ...
- Elasticsearch插件安装
从github获取插件包例如Head git clone git://github.com/mobz/elasticsearch-head.git 在elasticsearch安装目录中创建插件存放目 ...
- Springmvc+Spring+Mybatis整合开发(架构搭建)
Springmvc+Spring+Mybatis整合开发(架构搭建) 0.项目结构 Springmvc:web层 Spring:对象的容器 Mybatis:数据库持久化操作 1.导入所有需要的jar包 ...
- 执行SQL查询导致磁盘耗尽故障演示
a fellow in IMG wechat group 2 met an error about running out of disk space when using MySQL ...
- Docker Nginx安装(centos7)
docker search nginx docker pull nginx docker images nginx mkdir -p /data/nginx/{conf.d,html,logs} ...
- CentOS 7.x eth0
1:Test Environment [root@linux-node1 ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server rel ...
- sublime text3配置python开发环境(windows版)
安装阶段: sublime text3的安装: 下载网址:https://www.sublimetext.com/ 下载完成后 ,点击安装即可. 安装Package Control: 点击 Tools ...
- Python入门 —— 01简介
Python 历史 python 的创始人为荷兰人吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为 ...
- 关于“CheckBox”通过表单提交的问题
大多数时候CheckBox取值传到java后台都是通过js取值,ajax传值,今天改一离职同事的老代码,那家伙通过表单提交一些列的CheckBox设置,没想到的是后台死活接收不正常,name.valu ...