首页 > 其他 > 详细

lower_bound和upper_bound使用说明

时间:2019-03-28 21:59:23      阅读:201      评论:0      收藏:0      [点我收藏+]
#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;
}

 

lower_bound和upper_bound使用说明

原文:https://www.cnblogs.com/tonyyy/p/10617767.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!