破损的键盘,紫书P143UVa11988
来源:互联网 发布:我知谁掌管明天 歌曲 编辑:程序博客网 时间:2024/04/29 02:02
这到题刘用双数组模拟构建链表,刚开始理解起来比较费力,
尤其是对程序中“next[i] = next[cur];”这段语句的理解。
等到最后看明白后恍然大悟。对于本题来说,可以说是链表的经典应用。
// UVa11988 Broken Keyboard// Rujia Liu#include<cstdio>#include<cstring>const int maxn = 100000 + 5;int last, cur, next[maxn]; char s[maxn];int main() { while(scanf("%s", s+1) == 1) { int n = strlen(s+1); last = cur = 0; next[0] = 0; for(int i = 1; i <= n; i++) { char ch = s[i]; if(ch == '[') cur = 0; else if(ch == ']') cur = last; else { next[i] = next[cur]; next[cur] = i; if(cur == last) last = i; cur = i; } } for(int i = next[0]; i != 0; i = next[i]) printf("%c", s[i]); printf("\n"); } return 0;}
阅读全文
0 0
- 破损的键盘,紫书P143UVa11988
- 破损的键盘(链表)
- UVa 11988破损的键盘
- 【codevs 4650】破损的键盘
- 【codevs 4650】破损的键盘
- UVA 11988 破损的键盘
- 例题6-4 破损的键盘 UVa11988
- uva 11988 破损的键盘(链表)
- 破损的键盘(uva 11988)
- codevs 4650 破损的键盘(链表)
- 【codevs 4716】破损的键盘2
- codevs 4650 破损的键盘(链表)
- 破损的键盘(又名:悲剧文本)
- string+暴力——破损的键盘
- codevs 4650 破损的键盘(stl)
- 破损的键盘(Broken KeyBoard)Uva 11988
- 例题6-4 破损的键盘 UVa 11988
- UVa 11988 破损的键盘 链表 双向队列
- mvc框架
- Web项目文件的下载
- 算法导论-排序的Python&C++简单实现
- 安卓Debug
- spring mybatis整合框架时由于mybatis版本与mysql客户端不匹配出现的问题
- 破损的键盘,紫书P143UVa11988
- 及时通讯融云,如何取消系统通知图标右上角的数字
- C++拷贝构造函数详解
- ArrayList
- 粒子系统实现与用户交互的特效
- Go Hack 2017 报名开启:十月魔都约一场 Go 语言烧脑之战
- SpringMVC入门小示例
- Lottie的使用
- container_of分析