随笔分类 -  STL

acm
摘要:给定输入的序列 a(整数即可,其他无限制条件),next_permutation(a + 1, a + n + 1) 可以求出 a 的关于值的下一个排列,prev_permutation(a + 1, a + n + 1) 可以求出 a 的关于值的上一个排列 #include<bits/stdc++ 阅读全文
posted @ 2022-10-25 12:23 starlightlmy 阅读(60) 评论(0) 推荐(0)
摘要:定义map<int,int>mp; 假如我令 mp[2]=100; mp[5]=0; mp[0]=3; 输出结果: 可知,mp.count()是map中包含这个键的键值对数(一般为1或0,表示是否存在) mp[下标]是这个键对应的值(可以对应任何值) 阅读全文
posted @ 2022-08-05 18:34 starlightlmy 阅读(647) 评论(0) 推荐(0)
摘要:1 按数值从小到大输出 priority_queue<int,vector<int>,greater<int> >q; //可理解为值越来越大 2 按数值从大到小输出 priority_queue<int,vector<int>,less<int> >q; //可理解为值越来越小 3 默认值 相当于 阅读全文
posted @ 2022-05-18 13:17 starlightlmy 阅读(164) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> //普通括号匹配 using namespace std;int T;string s; int main(){ cin>>T; while(T--){ bool f=1; cin>>s; stack<char>q; for(int i=0;i<s.l 阅读全文
posted @ 2021-03-28 13:04 starlightlmy 阅读(86) 评论(0) 推荐(0)
摘要://第k小整数 c++写法 #include<cstdio>#include<algorithm>using namespace std;int a[10001]; int main(){ int n,k; scanf("%d%d",&n,&k); for(int i=0;i<n;i++) scan 阅读全文
posted @ 2021-03-28 12:53 starlightlmy 阅读(88) 评论(0) 推荐(0)
摘要:STL容器的基本用法 迭代器:用于遍历容器中数据的对象。按预先定义的顺序移动,所以不宜用it<s.end(); (封装过的指针) queue FIFOq.empty() 空返回1 不空返回0q.size() 队列大小q.push(元素名)q.pop() q.front()q.back()清空:循环出 阅读全文
posted @ 2021-03-28 12:52 starlightlmy 阅读(164) 评论(0) 推荐(0)