看板 C_and_CPP 關於我們 聯絡資訊
我想用C++ STL裡的lower_bound() 找出array裡的那個lower_bound的index int arr[10]; lower_bound(arr, arr+10, val); 我希望可以丟給lower_bound()的參數是array, 而不是vector 而實際上, 這樣的確可以compile過 但是lower_bound回傳的似乎是一個iterator 這讓我不知道該怎麼取得此iterator相對應的index 我有找到distance()這個function 不過他的input參數必須是兩個iterator 請問有什麼好的方法嗎 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.192.114
supyou5566:distance(arr,lower_bound(arr,arr+10,val)); 09/29 00:11