第三周实验报告4修改版
2012-03-10 13:01
183 查看
#include <iostream>
using namespace std;
class Cfz
{
public:
void get_data();
void display();
private:
int lengh;
int width;
int height;
int volume;
int acreage;
};
void Cfz::get_data()
{
cout<<"请输入长宽高:";
cin>>lengh;
cin>>width;
cin>>height;
}
void Cfz::display()
{
volume=lengh*width*height;
cout<<"长方柱体积为:"<<" "<<volume<<" ";
acreage=2*(lengh*height+width*height+lengh*width);
cout<<"长方柱表面积为:"<<acreage<<endl;
}
int main()
{
Cfz c1,c2,c3;
c1.get_data();
cout<<"第一个长方柱:"<<endl;
c1.display();
c2.get_data();
cout<<"第二个长方柱:"<<endl;
c2.display();
c3.get_data();
cout<<"第三个长方柱:"<<endl;
c3.display();
return 0;
}