UVA 10474 (暑假-排序、检索 -C - Where is the Marble?)

#include <cstdio>

int main() {
	int n, q;
	int count = 0;
	while (scanf("%d%d", &n, &q) && n) {
		printf("CASE# %d:\n", ++count);
		int arr[10100], brr[10100];
		for (int i = 0; i < n; i++) {
			scanf("%d", &arr[i]);
		}

		for (int i = 0; i < q; i++) {
			scanf("%d", &brr[i]);
			int num = 0, kong = 0;
			for (int j = 0; j < n; j++) {
				if (brr[i] == arr[j]) {
					kong = 1;
				}
				if (brr[i] > arr[j])
					num++;
			}
			if (kong)
				printf("%d found at %d\n", brr[i], num + 1);
			else
				printf("%d not found\n", brr[i]);
		}
	}
	return 0;
}

你可能感兴趣的:(UVA 10474 (暑假-排序、检索 -C - Where is the Marble?))