lower_bound和upper_bound使用说明

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a[10];
    for(int i=1;i<=10;i++)
    {
        a[i] = i*5;
    }
    for(int i=1;i<=10;i++)
        cout<<a[i]<<" ";
    cout<<endl;
    int it1 = lower_bound( a+1, a+10, 25) - a;
    //返回第一个大于等于25的位置
    int it2 = upper_bound( a+1, a+10, 25) - a;
    //返回第一个大于25的位置
    cout<<it1<<" "<<it2<<endl;

    return 0;
}
原文地址:https://www.cnblogs.com/tonyyy/p/10617767.html