STL算法库
文章平均质量分 51
Hormous的一天
这个作者很懒,什么都没留下…
展开
-
map与set的简单综合应用,统计单词词频
#include #include #include #include #include using namespace std; struct words{ string a; int numbers = 0; }; int main() { map mp; multimap mmp; char b[20];原创 2017-11-28 16:25:06 · 487 阅读 · 0 评论 -
STL函数库的简单了解
原创 2017-11-17 20:30:29 · 262 阅读 · 0 评论 -
二分查找算法 binary_search 和lower_bound
在一种查找规则下,就算是两种不一样的数据,比如98和8,在按照个位数字排序时是相等的原创 2017-11-17 21:10:26 · 385 阅读 · 0 评论 -
结构体的比较用法
一,万能比较,控制排序 struct Rule1{ bool operator()(const int &a,const int &b){ return (a%10) < (b%10); } }; 这个函数真的厉害,现在来看,可以用在容器中,可以用在普通的中。、其中的const int &a中,const 和 &可以省略有一点需要注意的是,其原创 2017-11-24 10:24:06 · 1606 阅读 · 0 评论 -
set 的简单使用和 pair 的简单介绍
大致的使用方法同multiset一致这个的用法厉害,用了一个pair来进行判断插入是否成功#include #include #include using namespace std; int main() { set st; int a[10] = {1,2,3,8,7,7,5,6,8,12}; for (int i = 0;i < 10;i ++)原创 2017-11-24 11:07:19 · 3009 阅读 · 0 评论 -
北大,STL简单整理 sort+二分搜索
greater包含在中,用了他,可以使sort从大到小排序。#include #include #include using namespace std; int main() { int a[] = {5,4,1,7,2,4}; sort(a,a+3,greater()); for (int i = 0;i < 6;i ++) printf("%d原创 2017-11-18 10:51:53 · 389 阅读 · 0 评论 -
C++(清华篇)STL的基本概念
复杂函数,中要把迭代器当成中间值 好吧,接下来的课就没有听懂了,到时候再来吧 上天啊,后面就完全看不懂了原创 2017-11-29 14:52:18 · 217 阅读 · 0 评论 -
map容器的使用 加上一个map与set综合运用的例子
string的函数赋值可以直接赋值。 #include #include #include using namespace std; struct Student{ string name; int score; }; Student students[5] = { {"Jack",89},{"Tom",74},{"Cindy",87},{"Alysa",87},{原创 2017-11-29 16:31:15 · 585 阅读 · 0 评论 -
next_permutation函数初识
#include #define MAX_M 10 #define MAX_N 10 using namespace std; bool used[MAX_N]; int perm[MAX_M]; // 生成{1,2,3,4,....,n-1}的n!种排列 void permutation1(int pos,int n){ if (pos == n){ cout <原创 2017-12-09 10:53:36 · 260 阅读 · 0 评论 -
map函数的简单使用,和用pair判断的有无正确插入
#include #include #include using namespace std; struct Student{ string name; int score; }; Student students[5] = { {"Jack",89},{"Tom",74},{"Cindy",87},{"Alysa",87},{"Micheal",98} }; typedef原创 2017-11-27 16:28:55 · 472 阅读 · 0 评论 -
multimap的简单使用 一道数据输入,查询的问题
cmd是用来接受命令的 然后需要把st中的元素插入mp中,虽然它们是可以对应起来的,但是毕竟类型是不同的 所以不能直接把st给插进去 那我们能够插入的是什么呢。 我们需要make a pair 就是make_pair这样的函数 mp.insert(make_pair(st.score,st.info)); 生成这个函数的时候,我们需要给他赋两个值 如果要查询的原创 2017-11-24 19:12:10 · 272 阅读 · 0 评论 -
平衡二叉树 STL multiset初识 再加上自定义的排序方法。
#include #include #include //使用multiset和set需要此文件 using namespace std; int main() { multisetst; int a[10]={1,14,12,13,7,13,21,19,8,8}; for (int i = 0;i < 10;i ++) st.insert(a[i]原创 2017-11-22 12:42:29 · 891 阅读 · 0 评论 -
string的加速及使用
令string加速输入的策略#include <bits/stdc++.h> using namespace std; string s; char a[100007]; string read(){ scanf("%s",a); string p = ""; for (int len = strlen(a),i = 0;i < len;i ++){ ...原创 2018-02-24 10:33:04 · 373 阅读 · 0 评论