2个回答
展开全部
#include <iostream>
using namespace std;
class rectangle
{
public:
double upper_left_x, upper_left_y, lower_right_x, lower_right_y;
rectangle(double ulx, double uly, double lrx, double lry)
:upper_left_x(ulx), upper_left_y(uly), lower_right_x(lrx), lower_right_y(lry){}
};
double area(const rectangle& rec)
{
return (rec.upper_left_y - rec.lower_right_y) * (rec.lower_right_x - rec.upper_left_x);
}
int main()
{
rectangle a(0,3,4,0);
cout << area(a);
}
using namespace std;
class rectangle
{
public:
double upper_left_x, upper_left_y, lower_right_x, lower_right_y;
rectangle(double ulx, double uly, double lrx, double lry)
:upper_left_x(ulx), upper_left_y(uly), lower_right_x(lrx), lower_right_y(lry){}
};
double area(const rectangle& rec)
{
return (rec.upper_left_y - rec.lower_right_y) * (rec.lower_right_x - rec.upper_left_x);
}
int main()
{
rectangle a(0,3,4,0);
cout << area(a);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询