http://acm.hdu.edu.cn/showproblem.php?pid=1412
没啥说的注意初始化就行了
3036199 | 2010-10-05 14:29:29 | Accepted | 1412 | 15MS | 240K | 495 B | G++ |
hdu1412
1 #include<stdio.h>
2 #include<string.h>
3 #include<stdlib.h>
4 #define max(x,y) (x)>(y)?x:y
5 #define min(x,y) (x)<(y)?x:y
6 #define N 1001
7 int cmp(const void *e,const void *f)
8 {
9 return *(int *)e-*(int*)f;
10 }
11
12 int main()
13 {
14 int a[2*N+2],i,m,n;
15 while(scanf("%d%d",&m,&n)!=EOF)
16 {
17 for(i=0;i<m+n;i++)
18 scanf("%d",&a[i]);
19 qsort(a,m+n,sizeof(a[0]),cmp);
20
21 printf("%d",a[0]);
22 for(i=1;i<m+n;i++)
23 if(a[i]!=a[i-1])
24 printf(" %d",a[i]);
25 putchar('\n');
26 }
27 return 0;
28 }
29