okok
2025-07-19 10:35:55
发布于:上海
16阅读
0回复
0点赞
#include<iostream>
#include<sstream>
#include<vector>
using namespace std;
int main()
{
string s,p;
int T;
cin>>s>>T;
vector<int>a;
stringstream str(s);
while(getline(str,p,','))
{
a.push_back(stoi(p));
}
int L=0,R=a.size()-1,M;
bool f=false;
while(L<=R)
{
M=L+(R-L)/2;
if(a[M]T)
{
f=true;
cout<<M;
break;
}
else if(a[M]>T)
R=M-1;
else L=M+1;
}
if(ffalse) cout<<-1;
}
这里空空如也
有帮助,赞一个