From MBo 's solution using a set :
struct cmp_div {
bool operator ()(const std::pair<int, int>& xy1, const std::pair<int, int>& xy2) const {
// x1/y1 < x2/y2
return xy1.first*xy2.second < xy2.first*xy1.second;
}
};
std::set<std::pair<int, int>, cmp_div> c;
c.emplace(6, 2);
c.emplace(9, 3);
std::cout << c.size(); // == 1