#include <algorithm> #include <iostream> #include <vector> using namespace std; struct Triangle { double a, b, c; Triangle() : a(0), b(0), c(0) {} Triangle(double a, double b, double c) : a(a), b(b), c(c) {} bool same(const Triangle& t)const { vector<double> xa{ a, b, c }; vector<double> xb{ t.a, t.b, t.c }; sort(xa.begin(), xa.end()); sort(xb.begin(), xb.end()); return xa == xb; } friend ostream& operator<<(ostream& out, const Triangle& t) { return out << "{ " << t.a << "; " << t.b << "; " << t.c << " }"; } }; int main() { Triangle a{ 2.5, 3.7, 2.9 }; Triangle b{ 3.7, 2.9, 2.5 }; Triangle c{ 2.9, 2.5, 3.6 }; cout << " A: " << a << "
B: " << b << "
C: " << c << "
"; puts(a.same(b) ? " A == B" : " A != B"); puts(a.same(c) ? " A == C" : " A != C"); puts(b.same(c) ? " B == C" : " B != C"); system("pause > nul"); }