题解 | #长方形的关系#

长方形的关系

https://www.nowcoder.com/practice/6b099f3a8e3745b592203f14e3954411

#include<bits/stdc++.h>
using namespace std;
class rectangle{
	private:
		int length,width;
	public:
		void set(int x,int y){
			length=x;
			width=y;
		}
		int getlength(){
			return length;
		}
		int getwidth(){
			return width;
		}
		int area(){
			return length*width;
		}
		// write your code here......
		string cancover(rectangle b){
			//if(this->length >= b.length && this->width >= b.width) return "yes";
			//if((this->length >= this->width ? this->length : this->width) >= (b.length >= b.width ? b.length : b.width) ) return "yes";
			//if(this->length  >= (b.length >= b.width ? b.length : b.width)  && this->width  >= (b.length <= b.width ? b.length : b.width) ) return "yes";
		if(
			(this->length >= this->width ? this->length : this->width) >= (b.length >= b.width ? b.length : b.width) &&
			(this->length <= this->width ? this->length : this->width) >= (b.length <= b.width ? b.length : b.width)
		
		) return "yes";
			else return "no";
		}
};
int main(){
	int l1,w1,l2,w2;
	cin>>l1>>w1>>l2>>w2;
	rectangle a,b;
	a.set(l1,w1);
	b.set(l2,w2);
	cout<<a.cancover(b);
	return 0;
}

两两对应,长的对应长的,短的对应短的,且前两者都大于后两着才能使得前者包含后者

全部评论

相关推荐

有担当的灰太狼又在摸鱼:零帧起手查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务