题解 | #长方形的关系#
长方形的关系
https://www.nowcoder.com/practice/6b099f3a8e3745b592203f14e3954411
#include<iostream> using namespace std; class rectangle { private: int length, width; public: rectangle(int a, int b) { length = a; width = b; } string cancover(rectangle b) { if (length >= b.getlength() && width >= b.getwidth())return "yes"; else return "no"; }; int getwidth() { return width; } int getlength() { return length; } }; int main() { int l1, w1, l2, w2; cin >> l1 >> w1 >> l2 >> w2; if (w1 > l1) { int t = w1; w1 = l1; l1 = t; } if (w2 > l2) { int t = w2; w2 = l2; l2 = t; } rectangle a(l1, w1), b(l2, w2); cout << a.cancover(b); return 0; }