UVA10474-Where is the Marble?

水题。。。不过要注意输出格式。。。

#include<stdio.h>
#include<string.h>
#include<algorithm>
#define N 10050
using namespace std;

int a[N], b[N];
int main(){
	int n, m, t = 0, flag;
	while(scanf("%d%d", &n, &m) == 2 && (m || n)){
		memset(a, 0, sizeof(a));	
		memset(b, 0, sizeof(b));	
		for(int i = 0; i < n; i++)			
			scanf("%d", &a[i]);	
		for(int i = 0; i < m; i++)	
			scanf("%d", &b[i]);	
		sort(a, a + n);			
		printf("CASE# %d:\n", ++t);	
		for(int i = 0; i < m; i++)
		{	
			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;
}














你可能感兴趣的:(UVA10474-Where is the Marble?)