View Code of Problem 83

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

Double click to view unformatted code.


Back to problem 83