您的位置:首页 > 编程语言 > C语言/C++

C++作业3.23

2015-04-01 16:43 190 查看
#include<iostream>

using namespace std;

const double pi=3.14;

class cylinder

{

public:

cylinder(double r,double h)

{

radius=r;

high=h;

 

} void vo1()

{ cout<<"半径:"<<radius<<" 高度:"<<high<<endl;

cout<<"圆柱的体积:"<<pi*high*radius*radius<<endl;

}

private:

double radius;

double high;

 

};

int main()

{ double r,h;

cout<<"请输入圆柱底圆半径:"<<endl;;

cin>>r;

cout<<"请输入圆柱高度:"<<endl;

cin>>h;

cylinder c1(r,h); 

c1.vo1();

system("pause");

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: