题解 | #比较长方形的面积大小#

比较长方形的面积大小

https://www.nowcoder.com/practice/61e0c4069baf474db635cd492ac9ba9c

#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;
		}
		void compare(rectangle b){
            // write your code here......
			if(this->length >= b.length && this->width >= b.width || this->length >= b.width && this->width >= b.length){
				cout<<1;
			}else{
				cout<<0;
			}
		}
};
int main(){
	int l1,w1,l2,w2;
	cin>>l1>>w1>>l2>>w2;
	rectangle a,b;
	a.set(l1,w1);
	b.set(l2,w2);
	a.compare(b);
	return 0;
}

全部评论

相关推荐

09-22 22:22
中山大学 Java
乌鱼子萨奇:羡慕你啊,直接转正了,都不用经历秋招的炼狱,但是你少经历了很多痛苦的事情啊
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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