https://vjudge.net/problem/UVA-10474
本题练习sort和lower_bound两个函数的使用
int main()
{
/*STL 练习
*/
/*UVa 10474
*sort和lower_bound两个函数的使用
*/
int n,t,a[10000],casee=0,x;
while(scanf("%d%d",&n,&t)==2&&n){
printf("CASE# %d:n",++casee);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
sort(a,a+n);
while(t--){
scanf("%d",&x);
int p = lower_bound(a,a+n,x)-a;
if(a[p]==x) printf("%d found at %dn",x,p+1);
else printf("%d not foundn",x);
}
}
return 0;
}
最后
以上就是知性手机最近收集整理的关于UVa 10474 Where is the Marble?【STL-sort、lower_bound】的全部内容,更多相关UVa内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复