Thursday, April 27, 2017

UVa 10474 Solution

UVa 10474







Solution: 

#include<bits/stdc++.h>
using namespace std;
int a[10001],b[10001];
int main()
{
    int n2,n,s,d,i,res,j,l;

    l=0;
    while(scanf("%d %d",&n,&n2)==2)
    {
        if(n==0&&n2==0) break;

        for(i=0; i<n; i++)cin>>a[i];
        for(i=0; i<n2; i++)cin>>b[i];

        sort(a,a+n);

        printf("CASE# %d:\n",++l);

        for(i=0; i<n2; i++)
        {
           res=0;
            for(j=0; j<n; j++)
            {
                if(b[i]==a[j]&&res!=1)
                {
                    printf("%d found at %d\n",b[i],j+1);
                    res=1;
                }
            }
            if(res==0)
                printf("%d not found\n",b[i]);
        }
    }

    return 0;
}
 

No comments:

Post a Comment