解题思路:如果一个坐标的x和y坐标都小于等于另外一个坐标,那么该坐标就不是极大点
注意事项:
参考代码:
#include<bits/stdc++.h>
using namespace std;
struct zb //结构体坐标
{
int x;//x坐标
int y;//y坐标
int f;//用来筛选条件符合的坐标
};
bool cmp(zb a, zb b)//按照x坐标大小自定义排序
{
return a.x < b.x;
}
int main()
{
int n;
cin >> n;
zb a[n];
zb b[n];
for(int i = 0; i < n; i++)
{
cin >> a[i].x >> a[i].y;
a[i].f=0;
}
for(int i = 0; i < n; i++)
{
int one = a[i].x;
int two = a[i].y;
for(int j = 0; j < n; j++)
{
if( j == i || a[j].f == 1)
{
continue;
}
if(one >= a[j].x && two >= a[j].y)
{
a[j].f = 1;
}
}
}
sort(a + 0, a + n, cmp);
int ff = 0;
for(int i = 0; i < n; i++)
{
if(a[i].f == 0)
{
if(ff == 0)
{
cout << "(" << a[i].x << "," << a[i].y << ")";
ff = 1;
}
else
{
cout << "," << "(" << a[i].x << "," << a[i].y << ")";
}
}
}
}
0.0分
1 人评分