我是靠谱客的博主 从容发卡,这篇文章主要介绍0018 Where is the Marble? UVA - 10474Where is the Marble? UVA - 10474总结,现在分享给大家,希望可以做个参考。
文章目录
- Where is the Marble? UVA - 10474
- 问题
- 代码
- 总结
Where is the Marble? UVA - 10474
问题


代码
// 算法竞赛入门经典系列源码解析
// 算法竞赛入门经典第2版 P108
// 算法竞赛入门经典 习题与解答
// 算法竞赛入门经典 训练指南
// 算法竞赛入门经典 算法实现
/*
Dreams never shine!
It's you that shine while chasing your dreams :)
JAYO!!
*/
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 10000;
int main() {
int n, q, x, a[maxn], kase = 0;
while(scanf("%d%d", &n, &q) == 2 && n) {
printf("CASE# %d:n", ++kase);
for(int i = 0; i < n; i++) scanf("%d", &a[i]);
sort(a, a + n);
while(q--) {
scanf("%d", &x);
int p = lower_bound(a, a + n, x) - a; // 在已经排序的数组a中寻找x
if(a[p] == x) printf("%d found at %dn", x, p + 1);
else printf("%d not foundn", x);
}
}
return 0;
}
总结
加油,知耻而后勇,厚积薄发,好好学习!!!
最后
以上就是从容发卡最近收集整理的关于0018 Where is the Marble? UVA - 10474Where is the Marble? UVA - 10474总结的全部内容,更多相关0018内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复