#include <iostream> #include <string> #include <functional> #include <vector> #include <algorithm>using namespace std;//内建仿函数-关系仿函数 // 使用内建函数对象的时候,需要引入头文件 functionalvoid printVector(vector<int>v) {for (vector<int>::iterator it = v.begin(); it != v.end(); it++){cout << *it << " ";}cout << endl; }void test01() {vector<int>v;v.push_back(12);v.push_back(122);v.push_back(2);v.push_back(1);v.push_back(102);printVector(v);//12 122 2 1 102//大于 greatersort(v.begin(), v.end(), greater<int>());printVector(v);//122 102 12 2 1//小于lesssort(v.begin(), v.end(), less<int>());printVector(v);//1 2 12 102 122}int main() { test01();system("pause");return 0; }