期中考试-试题一

来源:互联网 发布:表单生成器数据库设计 编辑:程序博客网 时间:2024/06/06 01:32
01./*      02.* 程序的版权和版本声明部分      03.* Copyright (c)2013, 烟台大学计算机学院学生      04.* All rightsreserved.      05.* 文件名称: .cpp                                 06.* 作    者:赵冠哲                                  07.* 完成日期:2013年5月25日      08.* 版本号: v1.0            09.* 输入描述:      10.* 问题描述:    11.*/     #include <iostream>using namespace std;class Rectangle{    public:        Rectangle(float x1=0,float y1=0,float x2=0,float y2=0):a(x1),b(y1),c(x2),d(y2){}        void input();        void output();    private:        float a;        float b;        float c;        float d;};void Rectangle::input(){    cin>>a>>b>>c>>d;}void Rectangle::output(){    if(d>b)    {        cout<<((c-a)*(d-b))<<endl;    }    else    {        cout<<((c-a)*(b-d))<<endl;    }}int main(){    Rectangle p1;    p1.input();    p1.output();    Rectangle p2(p1);    p2.output();    Rectangle p3(1,3,6,1);    p3.output();    return 0;}

原创粉丝点击