/*
* Copyright (c) 2013, 烟台大学计算机学院
* All rights reserved.
* 作 者:李子平
* 完成日期:2014 年 6 月 10 日
* 版 本 号:v1.0
* 输入描述:输入左下角和右上角坐标:3.7 0.4 6.5 4.9
输出:12.6 12.6 10
* 问题描述:定义一个矩形类,数据成员包括左下角和右上角坐标,输入坐标,计算矩形面积。
*/
#include<iostream>
using namespace std;
class Rectangle
{
public:
Rectangle(double po1=0,double po2=0,double po3=0,double po4=0)
:point1(po1),point2(po2),point3(po3),point4(po4){}
void input()
{
cin>>point1>>point2>>point3>>point4;
}
void output()
{
double s;
s=(point3-point1)*(point4-point2);
cout<<s<<endl;
}
private:
double point1,point2,point3,point4;
};
int main()
{
Rectangle p1;
p1.input();
p1.output();
Rectangle p2(p1);
p2.output();
Rectangle p3(1,1,6,3);
p3.output();
return 0;
}
输出结果:
心得体会:还差好多呢。。。。