64,282
社区成员
发帖
与我相关
我的任务
分享
#include <set>
#include <iostream>
using namespace std;
struct Coordinate{ //浮点型坐标 结构体
float x, y;
Coordinate(float xx, float yy){
x = xx;
y = yy;
}
bool operator <(const Coordinate &c) const{
return ((x < c.x) || (!(x < c.x) && (y < c.y) ) );
}
};
int main(){
set<Coordinate> s;
s.insert(Coordinate(0, 0)); //插入(0,0)
s.insert(Coordinate(0, 1)); //插入(0,1)
s.insert(Coordinate(1, 0)); //插入(1,0),出错
s.insert(Coordinate(1, 1)); //插入(1,1),出错
return 0;
}
struct Coordinate{ //浮点型坐标 结构体
float x, y;
Coordinate(float xx, float yy){
x = xx;
y = yy;
}
bool operator <(const Coordinate &c) const{
return ((x < c.x) || ((x == c.x) && (y < c.y) ) );
}
};