链表 UVA 11988 Broken Keyboard (a.k.a. Beiju Text)
题意:训练指南P244
分析:链表模拟,维护链表的head和tail指针
#include <bits/stdc++.h>
using namespace std; const int N = 1e5 + 5;
struct Link_list {
char ch;
Link_list *nex;
}link_list[N]; int main(void) {
while (true) {
Link_list *head = link_list;
Link_list *q = link_list + 1;
head -> nex = NULL;
Link_list *tail = head, *pos = head;
char c;
while (true) {
c = getchar ();
if (c == '\n') break;
if (c == EOF) return 0;
if (c != '[' && c != ']') {
Link_list *p = q++;
p -> ch = c;
p -> nex = pos -> nex;
pos -> nex = p;
pos = p;
if (tail -> nex != NULL) tail = pos;
}
else if (c == '[') pos = head;
else pos = tail;
}
Link_list *p = head -> nex;
while (p) {
printf ("%c", p -> ch);
p = p -> nex;
}
puts ("");
} return 0;
}
链表 UVA 11988 Broken Keyboard (a.k.a. Beiju Text)的更多相关文章
- 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 ...
- UVA 11988 Broken Keyboard (a.k.a. Beiju Text)(链表)
题目代号:UVA 11988 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&pa ...
- 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 ...
- UVA 11988 Broken Keyboard (a.k.a. Beiju Text) (链表,模拟)
使用list来模拟就行了,如果熟悉list,那么这道题真是分分钟秒掉... list是双向循环链表,插入和删除操作非常快,缺点是不能像数组一样随机按下标读取. 一下是wiki上说明的相关函数:http ...
- UVa 11988 Broken Keyboard (a.k.a. Beiju Text)
题目复制太麻烦了,甩个链接 http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18693 直接模拟光标操作时间复杂度较高,所以用链 ...
- 暑假集训单切赛第二场 UVA 11988 Broken Keyboard (a.k.a. Beiju Text)(字符串处理)
一开始不懂啊,什么Home键,什么End键,还以为相当于括号,[]里的东西先打印出来呢.后来果断百度了一下. 悲催啊... 题意:给定一个字符串,内部含有'['和']'光标转移指令,'['代表光标移向 ...
- UVa 11988 - Broken Keyboard (a.k.a. Beiju Text) 题解
刘汝佳的题目,悲剧文本 -_-||| 这里使用vector<string>容器倒置记录数据,然后从后面输出就能够了. 难度就是不知道这种文档究竟哪里是開始输出,故此使用动态管理内存的容器比 ...
- 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 ...
- 破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988)
破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988) 题意描述 你在输入文章的时候,键盘上的Home键和End键出了问题,会不定时的按下. ...
随机推荐
- js闭包原理
一.定义 官方解释:闭包是一个拥有许多变量和绑定了这些变量的环境的表达式(通常是一个函数),因而这些变量也是该表达式的一部分. ****定义在函数中的函数,并且可在外部访问得到.(正常情况下我们是无法 ...
- GridView中使用分页控件
前台:导入<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix= ...
- Android 更改字体
1. 将字体ttf文件放在assets目录下 2. 使用: Typeface mTypeFaceLight = Typeface.createFromAsset(context.getAssets() ...
- maximum subarray problem
In computer science, the maximum subarray problem is the task of finding the contiguous subarray wit ...
- C++联合
原文地址:http://ideage.javaeye.com/blog/210614 联合(union)在C/C++里面见得并不多,但是在一些对内存要求特别严格的地方,联合又是频繁出现,那么究竟什么是 ...
- .net学习笔记---lambda表达式(自执行方法)
http://www.cnblogs.com/jesse2013/p/happylambda.html#b034 lambda表达式 http://www.cnblogs.com/OceanEyes/ ...
- HTML5学习之文件操作(九)
之前我们操作本地文件都是使用flash.silverlight或者第三方的activeX插件等技术,由于使用了这些技术后就很进行跨平台的处理,另外就是让我们的web应用依赖了第三方的插件,而不是很独立 ...
- poj 1006:Biorhythms(水题,经典题,中国剩余定理)
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 110991 Accepted: 34541 Des ...
- SQL Server 2014 BI新特性(一)五个关键点带你了解Excel下的Data Explorer
Data Explorer是即将发布的SQL Server 2014里的一个新特性,借助这个特性讲使企业中的自助式的商业智能变得更加的灵活,从而也降低了商业智能的门槛. 此文是在微软商业智能官方博客里 ...
- wp8 入门到精通 Utilities类 本地存储+异步
public class CCSetting { public async static void AddOrUpdateValue<T>(string key, T value) { t ...