UVA11988 Broken Keyboard (a.k.a. Beiju Text)【数组模拟链表】
2024-08-27 02:29:45
参考:https://blog.csdn.net/lianai911/article/details/41831645
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
const int N=1e5+;//若在函数内开过大数组,会显示Process returned -1073741571 (0xC00000FD)错误!
string s;
vector<char> v[*N];
int main()
{
std::ios::sync_with_stdio(false);//加快cin,cout效率
std::cin.tie();
// freopen("btext.txt","r",stdin);
while (cin>>s)
{
int st=N,h=N-,e=N+;//st为当前光标,h为头,e为尾
for (int i=;i<*N;i++)
{
v[i].clear();
}
for (unsigned int i=;i<s.length();i++)
{
if (s[i]=='[')
{
st=h;
h--;
continue;
}
if (s[i]==']')
{
st=e;
e++;
continue;
}
v[st].push_back(s[i]);
}
for (int i=h;i<=e;i++)
{
for (unsigned int j=;j<v[i].size();j++)
{
cout<<v[i][j];
}
}
cout<<endl;
} return ;
}
最新文章
- Google C++单元测试框架GoogleTest---Google Mock简介--概念及基础语法
- JSon转化为DaTable
- Counterfeit Dollar -----判断12枚钱币中的一个假币
- html5调用手机相机并压缩、上传
- sp转dp dp转px
- 总结Selenium自动化测试方法(三)WebDriver定位元素方法
- php做站点购物车 你搞懂了吗?
- iOS MBProgressHUD 之带底板的加载提示
- MySQL数据备份方法
- Nginx正反向代理、负载均衡等功能实现配置
- Python机器学习笔记:深入理解Keras中序贯模型和函数模型
- 面试 -- requestLayout、invalidate与postInvalidate区别
- thinkphp5 列表页数据分页查询-带搜索条件
- 安装vs2008出现MSI returned error code 1603的错误的解决
- oracle long类型转换成varchar2
- elixir二进制模式匹配
- 智慧树mooc自动刷课代码
- [BZOJ4061][Cerc2012]Farm and factory
- Springboot监控之一:SpringBoot四大神器之Actuator之2--springboot健康检查
- leetcode104 Maximum Depth