View Code of Problem 83

#include<stdio.h>
int main(){
	int a,b,n;
	scanf("%d%d",&a,&b);
	n=a+b;
	int list[n][2];
	for(int i=0;i<n;i++){
		scanf("%d %d",&list[i][0],&list[i][1]);
	}
	int max=0;
	int tempnum,tempgrade;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			if(list[i][0]>list[j][0]){
				tempnum=list[i][0];
				tempgrade=list[i][1];
				list[i][0]=list[j][0];
				list[i][1]=list[j][1];
				list[j][0]=tempnum;
				list[j][1]=tempgrade;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(i!=n-1)
			printf("%d %d\n",list[i][0],list[i][1]);
		else
			printf("%d %d",list[i][0],list[i][1]);
	} 
}

Double click to view unformatted code.


Back to problem 83