forked from gmendonca/uri-problem-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1025.cpp
46 lines (38 loc) · 1001 Bytes
/
1025.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <stdlib.h>
int ascending(void const *a, void const *b )
{
return (*(int*)a - *(int*)b );
}
int achar(int ac[], int len, int comp)
{
for(int k = 0; k < len; k++){
if(ac[k] == comp){
return k+1;
}
}
return 0;
}
int main(){
int n,f,q,j,l;
n = 0;
for(;;){
scanf("%d", &f);
scanf("%d", &q);
if(f == 0 && q == 0) break;
int vet[f+1];
for(j = 0; j < f; j++){
scanf("%d",&vet[j]);
}
qsort(vet, f, sizeof(int), ascending);
printf("CASE# %d:\n",n+1);
for(j = 0; j < q; j++){
scanf("%d",&l);
int m = achar(vet,f,l);
if(m != 0) printf("%d found at %d\n",l,m);
else printf("%d not found\n",l);
}
n++;
}
return 0;
}