View Code of Problem 83

#include<stdio.h>
int main(){
	int i,j=0,a[100],b[100],n,k,w,m,min,temp;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d%d",&a[j],&b[j]);
		j++;
	}
	for(i=0;i<m;i++){
		scanf("%d%d",&a[j],&b[j]);
		j++;
	}
	for(i=0;i<m+n-1;i++){
		min=i;
		for(w=i;w<m+n;w++){
			if(a[w]<a[min])min=w;
		}
		temp=a[min];
		a[min]=a[i];
		a[i]=temp;
		temp=b[min];
		b[min]=b[i];
		b[i]=temp;
	}
	for(i=0;i<m+n;i++){
		printf("%d %d\n",a[i],b[i]);

	}
		return 0;
}

Double click to view unformatted code.


Back to problem 83