博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVa11988 Broken Keyboard (a.k.a. Beiju Text)
阅读量:7071 次
发布时间:2019-06-28

本文共 914 字,大约阅读时间需要 3 分钟。

模拟题.

但是可以借这题熟悉一下STL的list用法

首先, list有push_front 与 pop_front, 但显然, 这俩功能解决不了这个题

考虑使用迭代器和insert修改器.

查阅资料, insert插入单个元素时返回值为这个值的位置,

而且,

iterator insert( iterator pos, const T& value );

是在 pos 前插入 value

了解了这些, 不难写出程序.

1 #include 
2 #include
3 #include
4 #include
5 using namespace std; 6 const int HEAD = 0; 7 const int TAIL = 1; 8 9 list
l;string s;10 11 int main()12 {13 //freopen("11988.in", "r", stdin);14 ios::sync_with_stdio(false);15 char ch; list
::iterator it = l.begin();16 while(cin>>s)17 {18 for(int i = 0; i < (int) s.size(); i++)19 {20 ch = s[i];21 if(ch == '[') it = l.begin();22 else if(ch == ']') it = l.end();23 else it = l.insert(it, ch), it++;24 }25 for(it = l.begin(); it != l.end(); it++)26 cout<<*it;27 cout<

 

转载于:https://www.cnblogs.com/wsmrxc/p/9207281.html

你可能感兴趣的文章
:question.sync=”questionText”父子组件双向绑定
查看>>
jquery动画切换引擎插件 Velocity.js 学习02
查看>>
[Soot学习笔记][5]Soot依赖的两个框架
查看>>
[导入]构筑在GPRS之上的WAP应用
查看>>
POJ 2409 Let it Bead
查看>>
javase之四种内部类
查看>>
基于FPGA的AD0832
查看>>
[HEOI2014]平衡
查看>>
[SDOI2010]古代猪文
查看>>
错误使用find_last_of函数
查看>>
6远程管理常用命令
查看>>
sql日期函数操作
查看>>
Hive篇--相关概念和使用二
查看>>
PAT 解题报告 1048. Find Coins (25)
查看>>
mysql 函数 事务
查看>>
Django 碎片集合
查看>>
Merge与Rebase冲突的解决
查看>>
python中自定义排序函数
查看>>
微信快速开发框架(五)-- 利用快速开发框架,快速搭建微信浏览博客园首页文章...
查看>>
hdu-1532 Drainage Ditches---最大流模板题
查看>>