c++#include
#include
#include
using namespace std;class Point
{double x,y;
friend class Rectangle;
public:
Point()
{x=y=0;}
Point(double a,double b)
{x=a;y=b;}
double distance(Point& p1,Point& p2)
{return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
double distance(Point& p)
{return sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));
}
};class Rectangle
{Point lefttop,rightdown;
public:
Rectangle()
{Point lefttop,rightdown;
}
Rectangle(Point &p1,Point &p2)
{lefttop=p1;
rightdown=p2;
}
double area()
{
return abs((lefttop.x-rightdown.x)*(lefttop.y-rightdown.y));
}
};int main ()
{double a,b,c,d,area;
cout < < "Please enter the lefttop corner and the rightdown corner coordinates" << endl;
cin >> a >> b >> c >> d;
Point p1(a,b);
Point p2(c,d);
Rectangle s(p1,p2);
area=s.area();
cout < < "The area of the rectangle is " << area << endl;
system("pause");
}
非常简单你要求用什么语言编