欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

大理石在哪

程序员文章站 2024-03-18 23:22:10
...
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 10000;
int main()
{
	int n, q, x, a[maxn], kase = 0;
	while (scanf_s("%d%d", &n, &q) == 2 && n)
	{
		printf("CASE# %d:\n", ++kase);
		for (int i = 0; i < n; i++)	scanf_s("%d", &a[i]);
		sort(a, a + n);
		while (q--)
		{
			scanf_s("%d", &x);
			int p = lower_bound(a, a + n, x) - a;
			if (a[p] == x)	printf("%d found at %d\n", x, p + 1);
			else printf("%d not found\n", x);
		}
	}
	system("pause");
	return 0;
}