标签:
1 #include <stdio.h> 2 #include <string.h> 3 #include <algorithm> 4 using namespace std; 5 int a[110], b[110], c[110]; 6 int main() 7 { 8 int i, j, n, m, num, k; 9 while(~scanf("%d%d", &n, &m), n+m) 10 { 11 num = 0; 12 int flag; 13 //memset(a, 0, sizeof(a)); 14 //memset(b, 0, sizeof(b)); 15 for(i = 0; i < n; i++) 16 scanf("%d", &a[i]); 17 if(m == 0) 18 { 19 sort(a, a+n); 20 for(i = 0; i < n; i++) 21 printf("%d ", a[i]); 22 printf("\n"); 23 continue; 24 } 25 for(i = 0; i < m; i++) 26 scanf("%d", &b[i]); 27 k = 0; 28 for(i = 0; i < n; i++) 29 { 30 flag = 1; 31 for(j = 0; j < m; j++) 32 { 33 if(a[i] == b[j]) 34 { 35 flag = 0; 36 break; 37 } 38 } 39 if(flag) 40 { 41 c[k++] = a[i]; 42 } 43 } 44 if(!k || !n) 45 printf("NULL"); 46 else 47 { 48 sort(c, c+k); 49 for(i = 0; i < k; i++) 50 printf("%d ", c[i]); 51 } 52 printf("\n"); 53 54 } 55 return 0; 56 }
标签:
原文地址:http://www.cnblogs.com/digulove/p/4739816.html