首页 > 编程语言 > 详细

二分排序

时间:2019-02-02 00:40:10      阅读:210      评论:0      收藏:0      [点我收藏+]
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
void main()
{
    vector<unsigned> scores(0);
    for (decltype(scores.size()) ix = 0; ix < scores.size(); ++ix) {
        scores.push_back(ix);
    }
    sort(scores.begin(), scores.end());

    auto beg = scores.begin(), end = scores.end();
    auto mid = scores.begin() + scores.size() / 2;
    int a = 4;
    while (mid != end && *mid != a)
    {
        if (a < *mid)
            end = mid;
        else
            beg = mid + 1;
        mid = beg + (end - beg) / 2;
    }

    system("pause");
}

 

二分排序

原文:https://www.cnblogs.com/jingchu/p/10347376.html

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