
简单数据结构
qq_41854014
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
NC14661 简单的数据结构
因为要从队头队尾插入删除元素,可以用STL中的deque(双端队列)便于操作.这些是deque的一些基本操作:1.把x压入后/前端:push_back(x)/push_front(x)2.访问(不删除)后/前端元素:back()/front()3.删除后/前端元素:pop_back() pop_front()4.判断deque是否空:empty()5.返回deque的元素数量:size()6.清空deque:clear()7.排序:sort(d.begin(),d.end())#inclu原创 2020-06-16 16:27:50 · 235 阅读 · 0 评论 -
NC15029 吐泡泡
需要用栈去模拟整个过程.注意是多组数据输入.1.用str存储字符串,若str[i]与s.top()都是’o’,则出栈,s[i]=‘O’2.若str[i]与s.top()都是’O’,则出栈,i++3.否则str[i]入栈#include<bits/stdc++.h>using namespace std;const int maxn = 1000005;stack<char> s;string str;int main(int argc, char const *a原创 2020-06-09 10:43:21 · 184 阅读 · 0 评论 -
NC14893 栈和排序
1.用数组max_a存储i-n的最大值2.模拟入栈,贪心的思想:若当前栈顶元素i>max_a[i+1],则出栈.这样肯定是字典序最大的.#include<bits/stdc++.h>using namespace std;const int maxn = 1000005;int a[maxn];int max_a[maxn];int s[maxn];//s.push(), s.pop(), s.top();int main(int argc, char const *a原创 2020-05-29 11:27:42 · 118 阅读 · 0 评论