链表 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键出了问题,会不定时的按下. ...
随机推荐
- osg四元数设置roll pitch heading角度
roll绕Y轴旋转 pitch绕X轴旋转 heading绕Z轴旋转 单位是弧度,可以使用osg::inDegrees(45)将45角度转换为弧度 定义一个四元数 osg::Quat q( roll,o ...
- 'XCTest/XCTest.h' file not found
直接写解决方法吧:在报错的 Target 中的 Building Settings 中 Framework Search Paths 里面添加 $(PLATFORM_DIR)/Developer/Li ...
- C++多线程编程(入门实例)
多线程在编程中有相当重要的地位,我们在实际开发时或者找工作面试时总能遇到多线程的问题,对多线程的理解程度从一个侧面反映了程序员的编程水平. 其实C++语言本身并没有提供多线程机制(当然目前C++ 11 ...
- C --gettimeofday===获取某个程序经历的时间
#include <stdio.h> #include <sys/time.h> #include <time.h> int gettimeofday(struct ...
- Android 实现类似微信客户端朋友圈更新提示的小红点&栏目订阅
用到的类: com.jauker.widget.BadgeView 实现代码: BadgeView imageBadge = new BadgeView(getContext()); imageBad ...
- phpcms 标签
都说pc标签{pc:content参数名="参数值"参数名="参数值"参数名="参数值"} 但是 参数名对应的具体参数值有那些,菜鸟就不知道 ...
- 设置tomcat内存设定
Linux: 在/usr/local/apache-tomcat-/bin 目录下的catalina.sh添加: JAVA_OPTS='-Xms512m -Xmx1024m'要加"m&quo ...
- javascript - DOM对象控制HTML元素详解
1.方法 getElementsByName() -- 获取name getElementByTagName() -- 获取 getAttribute() --获取元素属性 se ...
- Hybrid App是如何实现网页语言与程序语言的混合?谁占主体?
[编者按]本文作者@徐珂铭,一位看好Html5的移动互联网的从业人士.喜爱玩技术,会点JAVA.HTML及CSS,有自己的想法及姑且能表达想法的文字,因此有了自己的文章. 基于HTML5的Web Ap ...
- [LeetCode] Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is ...