-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVA10474.cpp
More file actions
32 lines (32 loc) · 739 Bytes
/
UVA10474.cpp
File metadata and controls
32 lines (32 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<stdio.h>
#define swap(x,y,z) ((z)=(x),(x)=(y),(y)=(z))
void sort(int arr[],int size) {
int temp;
for (int i = 0; i < size - 1; i++) {
for (int j = 0; j < size - i - 1; j++) {
if (arr[j] > arr[j + 1]) swap(arr[j], arr[j + 1], temp);
}
}
}
int main()
{
int nums[10010], quer, q, n, casen=0;
while (scanf("%d %d", &n, &q) != EOF && n) {
printf("CASE# %d:\n",++casen);
for (int i = 0; i < n; i++)
scanf("%d", &nums[i]);
sort(nums,n);
for (int i = 0; i < q; i++) {
scanf("%d", &quer);
int f = 1;
for (int j = 0; j < n && quer >= nums[j]; j++) {
if (quer == nums[j]) {
printf("%d found at %d\n", quer, j + 1);
f = 0;
break;
}
}
if (f) printf("%d not found\n", quer);
}
}
}