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;
}
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;
}