#P1799. 坐标排序.运算符定义.填空题

坐标排序.运算符定义.填空题

题目描述

输入 nn 个不同的坐标,按 xx 轴的值从小到大排序,如果 xx 相同,则按照 yy 排序。

输入格式

第 1 行是一个整数 nnn10000n \le 10000 )。

接下来有 nn 行,每行有 2 个整数,代表了 1 个点的坐标。

输出格式

输出 nn 行,每行有 2 个整数,输出排序后的 nn 个坐标。

样例

4
-1 -1
1 1
-1 1
1 -1
-1 -1
-1 1
1 -1
1 1

完善程序

#include<bits/stdc++.h>
using namespace std;
struct Point
{
	int x,y;
}a[10000];
bool __填空(1)__ < (Point i,Point j)
{
	return i.x<j.x||(i.x==j.x&&i.y<j.y);
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d %d",&a[i].x,&a[i].y);

	sort(__填空(2)__);

	for(int i=0;i<n;i++)
		printf("%d %d\n",a[i].x,a[i].y);

	return 0;
}

填空(1):{{ input(1) }}

填空(2):{{ input(2) }}

#include<bits/stdc++.h>
using namespace std;
struct Point
{
	int x,y;
    __填空(3)__ < (__填空(4)__)
    {
        return x<other.x||(x==other.x&&y<other.y);
    }
}a[10000];


int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d %d",&a[i].x,&a[i].y);

	sort(__填空(5)__);

	for(int i=0;i<n;i++)
		printf("%d %d\n",a[i].x,a[i].y);

	return 0;
}

填空(3):{{ input(3) }}

填空(4):{{ input(4) }}

填空(5):{{ input(5) }}