#include <iostream>
using namespace std ;
#include <cmath>
class cylinder
{
private :
double radius;
double high;
double volume;
public :
cylinder (double r,double h )
{
high = h ;
radius = r ;
volume = v() ;
}
double v ()
{
return M_PI*radius*radius*high;
}
void vol ()
{
std::cout << "圆柱的体积是; " << volume << std::endl;
}
} ;
int main ()
{
double r,h ;
cout << "请输入圆柱体的半径和高:"<< endl;
cin >> r >> h ;
cylinder voi(r,h) ;
voi.vol();
return 0 ;
}
计算圆柱体的体积
最新推荐文章于 2025-04-27 22:48:21 发布