题目链接:

https://cn.vjudge.net/problem/UVA-11988

 /*
问题 将一段文本经过一定的规则处理后输出,规则就是[表示home键,表示光标跳到行首,]表示end键,表示光标跳到行末 解题思路
可以发现[]是可以嵌套的,采用纯模拟比较复杂,采用类似KMP中的next数组一样,记录一下每个字符的下一个字符位置,最后
输出即可。
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<list>
const int maxn=;
using namespace std; char str[maxn];
int nex[maxn];
int main()
{
int i,len,cur,las;
//freopen("E:\\testin.txt","r",stdin);
while(scanf("%s",str+) != EOF){
len=strlen(str+);
cur=las=;
nex[]=;
for(i=;i<=len;i++){
if(str[i] == '[')
cur=;
else if(str[i] == ']')
cur=las;
else{
nex[i]=nex[cur];
nex[cur]=i;
if(cur == las) las = i;
cur =i;
}
} for(i=nex[];i != ;i=nex[i]){
printf("%c",str[i]);
}
puts("");
}
return ;
}

UVa 11988 Broken Keyboard(数组模拟链表)的更多相关文章

  1. UVa 11998 Broken Keyboard (数组模拟链表问题)

    题目链接: 传送门 Broken Keyboard #include<bits/stdc++.h> using namespace std; char str[100010]; int m ...

  2. UVa 11988 Broken Keyboard(链表->数组实现)

    /*数组形式描述链表:链表不一定要用指针. 题目链接:UVa 11988 Broken Keyboard 题目大意: 小明没有开屏幕输入一个字符串,电脑键盘出现了问题会不定时的录入 home end ...

  3. UVA 11988 Broken Keyboard (a.k.a. Beiju Text)(链表)

    题目代号:UVA 11988 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&pa ...

  4. Uva 11988 Broken Keyboard STL+链表

    两种方法,直接上代码 STL标准模板库 #include <iostream> #include <list> #include <algorithm> #incl ...

  5. 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 ...

  6. 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 ...

  7. UVA 11988 Broken Keyboard (a.k.a. Beiju Text) (链表,模拟)

    使用list来模拟就行了,如果熟悉list,那么这道题真是分分钟秒掉... list是双向循环链表,插入和删除操作非常快,缺点是不能像数组一样随机按下标读取. 一下是wiki上说明的相关函数:http ...

  8. 链表 UVA 11988 Broken Keyboard (a.k.a. Beiju Text)

    题目传送门 题意:训练指南P244 分析:链表模拟,维护链表的head和tail指针 #include <bits/stdc++.h> using namespace std; const ...

  9. UVA 11988 Broken Keyboard (链表)

    简单题,题目要求显然是很多次插入,所以是链表. 插入两个语句,nxt[i] = nxt[u] 表示 i结点指向u的后继, nxt[u] = i表示把u的后继设成i. 设置一个头结点,指向一个不存在的结 ...

随机推荐

  1. LCA的 RMQ解法模版

    struct Edge{ int from, to, nex; }edge[N<<1]; int head[N], edgenum; void addedge(int u, int v){ ...

  2. iOS 5 故事板进阶(1)

    译自<iOS 5 by tutorials> 在上一章,你已经学习了故事板的基本用法.包括如何向故事板中添加 View Controller,通过 segues 切换 View Contr ...

  3. Android-Kotlin-抽象类与多态的表现

    选择包名,然后右键: 选择Class类型,会有class:  选择File类型,不会自动有class: 目录结构: 定义描述抽象类 Person人类: package cn.kotlin.kotlin ...

  4. WinForm企业级框架实战项目演练

    一.课程介绍 我们都知道在软件架构方式分为:C/S和B/S两类.这里阿笨不谈论两种软件架构的优劣之分,因为它们各有千秋,用于不同场合.一位伟大的讲师曾经说过一句话:事物存在即合理!录制这堂课程的目的就 ...

  5. MS SQL的某一数据库成了Single User模式

    数据库恢复失败,原来的数据却变成了 当尝试打开数据库的属性,即出现上面图片异常的信息. 正常来说,是可以打开数据库的属性 此刻,你可以运行SQL语句来解决: USE master; GO ALTER ...

  6. boost bind及function的简单实现

    前面在做 http server 的时候,需要做一个回调的接口,要求能够绑定类的函数以及普通的函数到这个回调里,对于这种应用要求,选择 boost 的 bind 和 function 是最合适不过了, ...

  7. GitLab问题小结

    1.内存消耗太大 (1)公司使用gitlab后,发现服务器内存居高不下,使用top命令查看内存消耗,发现服务器上git将近消耗一半内存资源.而且很奇怪的是竟然开启了32个进程.后经查资料,原来这跟gi ...

  8. git 下载指定tag版本的源码

    git clone --branch x.x.x https://xxx.xxx.com/xxx/xxx.git

  9. 【有新题】OCP 12c 062出现大量新考题-14

    choose two You plan to upgrade your Oracle Database 9i to Oracle Database 12c. Which two methods can ...

  10. MySQL 中文字符集排序

    SELECT 字段名 FROM 表 ORDER BY CONVERT(字段名 USING gbk) ASC;