惭愧啊,自己还是容易受到外界影响,今天只花了3个小时学习算法,
中午看到同学在玩DDCTF就上手做了一题,没想到就没停下来..撸了7个小时逆向..没有时间整理知识了..
导致今天的计划没有完成.
又要肝一会了..洗个澡先...
以下是对f_zyj大佬模板中提供的algorithm算法库相关函数的测试和注解
f_zyj大佬的博客:
http://blog.youkuaiyun.com/f_zyj/article/details/51594851
地址为pdf中第21页
#define pause system("pause");
#define fence puts("-------------");
#define endline puts("")
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
//adjacent_find(first,last(,cmp))
//STL非变易算法(Non-mutating algorithms)
//是一组不破坏操作数据的模板函数,
//用来对序列数据进行逐个处理、元素查找、子序列搜索、统计和匹配。
//功能:查找一个迭代器区间内,相等或满足自定义条件的第一个邻近元素对
//返回:找到的一个元素对的第一个元素的位置,
// 找不到返回last位置
vector<int>a;
a.push_back(0);
a.push_back(1);
a.push_back(1);
a.push_back(2);
auto j1 = adjacent_find(a.begin(), a.end());
auto j2 = adjacent_find(a.begin(), a.end(), [](int n, int m) { return n < m; });
cout << *j1 << " " << *j2;
endline;
fence;
//binary_search
//功能:查找一个有序迭代器区间内是否存在某个元素
//返回:true false
auto bs = binary_search(a.begin(), a.end(), 1);
cout << bs;
endline;
fence;
//copy
//功能:将一个迭代器区间的内容复制到另一个迭代器区间
//(利用这个函数进行输出输入见上一篇博客iterator)
vector<int>c(4);
auto tc = copy(a.begin(), a.end(), c.begin());
for (auto i : c)cout << i << " ";
endline;
fence
pause
}
/*
运行结果
1 0
-------------
1
-------------
0 1 1 2
-------------
*/