代码:
#include <iostream.h>
struct POINT
{
double x;
double y;
};
struct RECTANGLE
{
POINT ptlefttop;
POINT ptrightbottom;
};
double Area(RECTANGLE rec)
{
double recarea;
recarea=(rec.ptlefttop.y-rec.ptrightbottom.y)*(rec.ptrightbottom.x-rec.ptlefttop.x);
return recarea;
}
void main()
{
RECTANGLE rec;
cout<<"请输入长方形左上角顶点坐标:"<<endl;
cout<<"x=";
cin>>rec.ptlefttop.x;
cout<<"y=";
cin>>rec.ptlefttop.y;
cout<<"请输入长方形右下角顶点坐标:"<<endl;
cout<<"x=";
cin>>rec.ptrightbottom.x;
cout<<"y=";
cin>>rec.ptrightbottom.y;
cout<<"长方形面积:"<<Area(rec)<<endl;
}
http://s11/middle/63a7c6abnbbcb7ad7c32a&690
加载中,请稍候......