#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
int Sort(int x[],int t,int l,int u)
{
if(l>u) return -1;
int m=(l+u)/2;
if(x[m] > t)
u=m-1;
else if(x[m] < t)
l=m+1;
else
{
while(m>=0 && x[m]==t)
m--;
return m+1;
}
return Sort(x,t,l,u);
}
int main()
{
int arry[]={1,2,3,3,3,6,7,8};
cout<<Sort(arry,3,0,7);
system("pause");
return 0;
}
编程珠玑 课后题答案 4.2
最新推荐文章于 2023-06-17 12:41:03 发布