#include <iostream>
#include <algorithm>
#include <vector>
#include <ctime>
using namespace std;
//比较函数
bool cmp(int a, int b) //a是否排在b的前面,即下一个数是否排在当前数的前面
{
// return a % 2 == 0; //偶数往前排
// return a = b; //连续的相同元素放前面
return a > b;
}
int main()
{
vector<int> a, b;
a = {5, 7, 8, 4, 1, 1};
b = {2, 2, 4, 4, 5, 5, 1};
int arr[] = {2, 2, 4, 4, 5, 5, 1};
//unique返回的是去重后末尾元素的下一号元素的位置(指针)
// int* m = unique(arr, arr + 7);
// cout << *m << endl;
/*
由于返回的是去重后末尾下一个元素的位置,
如需要统计不重复元素个数则需要减去一个初始位置
*/
// int m = unique(arr, arr + 7) - arr ;
// int n = unique(b.begin(), b.end()) - b.begin();
// cout << m << ' ' << n << endl;
// for(int i = 0; i < m; i ++) cout << arr[i] << ' ';
// cout << endl;
// for(int i = 0; i < n; i ++) cout << b[i] << ' ';
// cout << endl;
//删除末尾重复元素
// b.erase(unique(b.begin(), b.end()), b.end());
// for(auto x : b) cout << x << ' ';
//time(0)返回当前时间到1970.1.1的秒数
// srand(time(0)); //传入time(0)当随机种子,使随机数列不同
// random_shuffle(a.begin(), a.end());
// for(auto x : a) cout << x << ' ';
// cout << endl;
// sort(a.begin(), a.end()); //排序:从小到大
// sort(a.begin(), a.end(), cmp); //第三个参数为比较函数
// for(auto x : a) cout << x << ' ';
// cout << endl;
int p = lower_bound(arr, arr + 7, 6) - arr; //返回>=6的最小元素的下标
cout << p << endl;
return 0;
}