#include<bits\stdc++.h>
using namespace std;
int bin_search(vector<int> &nums, int target){
int left=0;
int right=nums.size()-1;
while(left<right){
int mid = (left+right)/2;
if(nums[mid]>target) right=mid;
else if(nums[mid]<target) left=mid+1;
else return mid;
}
return left;//找不到target,返回target插入的位置
}
int main(){
vector<int> nums={1,2,3,5,6,7,9};
for(int i=0;i<11;i++){
cout<<i<<"target: "<<bin_search(nums, i)<<endl;
}
return 0;
}