#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main() { int n,m,temp,temp1,i,j; int a[1000],b[1000]; scanf("%d %d",&n,&m); for(i=0;i<n+m;i++){ scanf("%d %d",&a[i],&b[i]); } for(i=0;i<n+m;i++){ for(j=i+1;j<n+m;j++){ if(a[i]>a[j]){ temp=a[i]; a[i]=a[j]; a[j]=temp; temp1=b[i]; b[i]=b[j]; b[j]=temp1; } } } for(i=0;i<n+m;i++){ printf("%d %d\n",a[i],b[i]); } } |
Double click to view unformatted code.