小编Zyl*_*der的帖子

上限/下限不像我预期的那样工作,不明白为什么

这是代码.结果我得到"4 4".不明白为什么它不是"2 4"(根据下限和上限的'defenitions).

#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> v = {1, 2, 4, 5};
    vector<int>::iterator s , f;
    s = lower_bound(v.begin(), v.end(), 3);
    f = upper_bound(v.begin(), v.end(), 3);
    cout << (*s) << " " << (*f);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ lower-bound upperbound

2
推荐指数
1
解决办法
123
查看次数

标签 统计

c++ ×1

lower-bound ×1

upperbound ×1