格式:lower_bound(str,str+n,x)-str.
#include <cstdio>#include <algorithm>//必須包含的頭文件 using namespace std;int main(){ int point[10] = {1,3,7,7,9}; int tmp = upper_bound(point, point + 5, 7) - point;//按從小到大,7最多能插入數(shù)組point的哪個(gè)位置 PRintf("%d/n",tmp); tmp = lower_bound(point, point + 5, 7) - point;////按從小到大,7最少能插入數(shù)組point的哪個(gè)位置 printf("%d/n",tmp); return 0;}output:
2
4
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注