uva 10474

题意:找出所要求数字的位置
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n,q;
int a[10005];
int b[10005];

int main()
{
	int t = 1;
	while (scanf("%d%d",&n,&q)!=EOF && n+q)
	{
		for (int i = 0 ; i < n ; i++)
			cin>>a[i];
		for (int i = 0 ; i < q ; i++)
			cin>>b[i];

		sort(a,a+n);

		printf("CASE# %d:\n",t++);
		for (int i = 0 ; i < q ; i++)
		{
			int flag = 1 ;
			for (int j = 0 ; j < n ; j++)
			{
				if (b[i] == a[j])
				{
					printf("%d found at %d\n",b[i],j+1);
					flag = 0 ;
					break;
				}
			}
			if (flag)
				printf("%d not found\n",b[i]);
		}
	}
	return 0;
}


你可能感兴趣的:(uva 10474)