Uva 11988 Broken Keyboard】的更多相关文章

/*数组形式描述链表:链表不一定要用指针. 题目链接:UVa 11988 Broken Keyboard 题目大意: 小明没有开屏幕输入一个字符串,电脑键盘出现了问题会不定时的录入 home end 两个键, 我们知道如果录入home则将光标定位到字符首,如果录入end则是将光标定位到字符尾.现 在让你输出这段坏了文本. 表示:home => '[' , end => ']' 举例: input: hello[_Tom_]! output: _Tom_hello! 解题思路: 数组中频繁移动元…
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 withthe keyboard is that sometimes the “home” key or the “end” key gets automatically pressed (internally).You’…
题目代号:UVA 11988 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3139 You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problemwith the keyboard is that…
You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem with the keyboard is that sometimes the "home" key or the "end" key gets automatically pressed (internally). You're not aware of this iss…
因为要经常移动这些字符,所以采用的数据结构是链表. next[i]起到的作用大概就是类似链表里的next指针. 0.需要注意的是,判断cur == last ? 如果 是 则 last=i 1.另外一点是,输入的时候把next[0]空出来,起链表里面空白头结点的作用.所以输入的时候有个小改动 从s+1开始填入字符,计算长度的时候也是从s+1开始计算,s代表的是这个数组的首地址. 2.直接往oj上交的时候要注意,next数组名要改一下 2. )) { ); ...... } #include <i…
题目传送门 题意:训练指南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 = li…
题目复制太麻烦了,甩个链接 http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18693 直接模拟光标操作时间复杂度较高,所以用链表存储顺序. pos表示光标位置 #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<cmath> using namespace st…
一开始不懂啊,什么Home键,什么End键,还以为相当于括号,[]里的东西先打印出来呢.后来果断百度了一下. 悲催啊... 题意:给定一个字符串,内部含有'['和']'光标转移指令,'['代表光标移向文章头,']'代表光标移向文章尾,问最终在屏幕上显示的字符串序列是什么 思路:直接模拟一下即可,不过因为由于会可能移动到字符串开头以及结尾,所以我开了3个char数组. str1存储由于'['的原因而打印在开头的字符,str3存储由于']'的原因打印在结尾的字符,str2则是存储一开始在没遇到'['…
刘汝佳的题目,悲剧文本 -_-||| 这里使用vector<string>容器倒置记录数据,然后从后面输出就能够了. 难度就是不知道这种文档究竟哪里是開始输出,故此使用动态管理内存的容器比較好做. 添加了io处理的O(n)算法也没有上榜,郁闷. #include <stdio.h> #include <vector> #include <string> using std::vector; using std::string; const int MAX_B…
两种方法,直接上代码 STL标准模板库 #include <iostream> #include <list> #include <algorithm> #include <cstdio> using namespace std; const maxn=100000+5; char str[maxn]; typedef list<char> L; int main(){ while(gets(str)){ L l; L::iterator p;…