代码
#include<bits/stdc++.h>
using namespace std;
int a[110000],n,q;
int zc(int x)
{
int l=1,r=n,mid;
while(l<=r)
{
mid=(l+r)/2;
if(x<a[mid]) r=mid-1;
else if(x>a[mid]) l=mid+1;
else if(x==a[mid]) r=mid-1;
}
if(a[l]==x) return l;
else return -1;
}
int main()
{
int i,x;
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
cin>>q;
for(i=1;i<=q;i++)
{
cin>>x;
cout<<zc(x)<<" ";
}
return 0;
}