#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
	int n;
	scanf("%d", &n);
	int a[n], b[n];
	
	for(int f=0; f<n; f++)
	{
	    scanf("%d %d", &a[f], &b[f]);
	}
	
	for(int i=0; i<n-1; i++) //바퀴 반복
    {
        for(int j=0; j<n-1-i; j++) //비교활동 반복
        {
            if(a[j] > a[j+1])
            {
                int t; // 임시 저장
                int m; // b 임시저장
                t=a[j];
                m = b[j];
                a[j] = a[j+1];
                b[j] = b[j+1];
                a[j+1] = t;
                b[j+1] = m;
            }
        }
    }

    for(int i=0; i<n; i++)
    {
        printf("%d %d\n",a[i], b[i]);
    }
	
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: