STL二分查找

#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

int main()
{
    double num[10]={1,2,3,4,4,5,5,5,6,7},a;
    while(cin>>a && a)
    {
        cout<<upper_bound(num,num+10,a)-num<<endl;  //查比a来的大的第一个数的下标
        cout<<lower_bound(num,num+10,a)-num<<endl;  //查比a大的数或者等于a的第一个数的下标
        cout<<endl;
    }
    return 0;
}
全部评论

相关推荐

学历算污点吗?
小何和:快毕业了,BOSS上的od闻着味就来了
点赞 评论 收藏
分享
frutiger:逆天,我家就安阳的,这hr咋能说3k的,你送外卖不比这工资高得多?还说大厂来的6k,打发叫花子的呢?这hr是怎么做到说昧良心的话的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务