#include<iostream>
using namespace std;
class cylinder
{
public:
cylinder(double r,double h);
void vol();
private:
double V;
};
cylinder::cylinder(double r,double h)
{
V=(r*r*3.14*h);
}
void cylinder::vol()
{
cout<<"圆柱体的体积为:"<<V<<endl;
}
int main()
{
double r;double h;
cout<<"请输入圆柱体的半径:";
cin>>r;
cout<<"请输入圆柱体的高:";
cin>>h;
cylinder cyl1(r,h);
cyl1.vol();
system("pause");
return 0;
}
03-26
06-28
08-15
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交