链表 UVA 11988 Broken Keyboard (a.k.a. Beiju Text)
2016-01-14 13:17
609 查看
题目传送门
题意:训练指南P244
分析:链表模拟,维护链表的head和tail指针
题意:训练指南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 ; 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; }
相关文章推荐
- ping包过NAT如何处理
- 设计模式-单例模式
- javamail实践
- 使用zTree实现树形下拉框
- Javascript定义类(class)的三种方法
- Android studio中使用xUtils报错
- Android socket通信
- poj 1845 Sumdiv 约数和定理
- EXCEL中如何查找通配符本身(*?)
- 查看安全码SHA1
- Java有序数组的实现
- Swift中的实例方法--柯里化方法(Curried Functions)
- [文章摘要]SeMiTri: A Framework for Semantic Annotation of Heterogeneous Trajectories
- Android之SurfaceView使用总结
- 移动端 transition动画函数的封装(仿Zepto)以及 requestAnimationFrame动画函数封装(仿jQuery)
- SFTP例子2----使用JSch实现SFTP文件传输
- 使用 Anotation 注释出现Exception org.hibernate.MappingException: An AnnotationConfiguration。。。
- Subversion中创建项目,导入项目,导出项目
- 51单片机定时器0中断时执行外部中断0
- git操作命令