View Code of Problem 83

#include <stdio.h>
#include <string.h>
#include <math.h>
#define N 100
typedef struct SNode
{
	int xh;
	int cj;
};

int main()
{
	struct SNode a[N],b[N],c[N];
	int m,n;
	int i,j,k;
	struct SNode temp;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
		scanf("%d%d",&a[i].xh,&a[i].cj);
	for(i=0;i<m;i++)
		scanf("%d%d",&b[i].xh,&b[i].cj);
	for(i=0;i<n;i++)
	{
		c[i].xh=a[i].xh;
		c[i].cj=a[i].cj;
	}	
	for(i=n;i<m+n;i++)
	{
		c[i].xh=b[i-n].xh;
		c[i].cj=b[i-n].cj;
	}
	for(i=0;i<m+n;i++)
	{
		k=i;
		for(j=i;j<m+n;j++)
			if(c[j].xh<c[k].xh)
			{
				temp=c[j];
				c[j]=c[k];
				c[k]=temp;
			}
	}
	for(i=0;i<m+n;i++)
	{
		printf("%d %d\n",c[i].xh,c[i].cj);
	}
}

Double click to view unformatted code.


Back to problem 83