第一周项目二

来源:互联网 发布:三菱plc模拟量编程 编辑:程序博客网 时间:2024/05/22 11:42
/*    *Copyright (c)2015,烟台大学计算机与控制工程学院    *All rights reserved.    *文件名称:score.cpp    *作    者:战九州    *完成日期:2015年3月18日    *版 本 号:v1.0    *    #include <iostream>#include <cmath>using namespace std;class Volume{public:    void set_length( double l);    void set_width( double w);    void set_heigth( double h);    double  volume();    double areas();private:    double length;    double width;    double heigth;};void Volume::set_length( double l){    length=l;}void  Volume::set_width( double w){    width=w;}void  Volume::set_heigth( double h){    heigth=h;}double Volume::volume(){    return length*width*heigth;}double  Volume::areas(){    return 2*(length*width+length*heigth+width*heigth);}int main(){    int i;    for(i=0; i<3; i++)    {        double l,w,h;        cin>>l>>w>>h;        Volume v;        v.set_length(l);        v.set_width(w);        v.set_heigth(h);        cout<<v.volume()<<endl;        cout<<v.areas()<<endl;    }    return 0;}

0 0
原创粉丝点击