# G 圆到圆柱体

G 圆到圆柱体

Circle圆形类定义如下:
class Circle
{
public:
protected:
};

#include <iostream>
#include <iomanip>
using namespace std;
#define PI 3.14

class Circle
{
public:
protected:
};

//将程序需要的其他成份写在下面，只提交begin到end部分的代码
//******************** begin ********************

//********************* end ********************

int main()
{
double r,h;
cout<<setiosflags(ios::fixed);
cout<<setprecision(2);
cin>>r;
Circle c(r);
cout<<c.area()<<endl;
cin>>r>>h;
Cylinder cy(r,h);
cout<<cy.area()<<" "<<cy.volume()<<endl;
return 0;
}

``````1
2 2.5
``````

``````3.14
56.52 31.40
``````

``````#include<stdio.h>
int main()
{
float pi=3.14,a,b,c;
scanf("%f",&a);
scanf("%f%f",&b,&c);
printf("%.2f\n%.2f %.2f",pi*a*a,2*pi*b*c+2*pi*b*b,pi*b*b*c);
}``````

``````
#include <iostream>
#include <iomanip>
using namespace std;
#define PI 3.14

class Circle
{
public:
protected:
};

//将程序需要的其他成份写在下面，只提交begin到end部分的代码
//******************** begin ********************

class Cylinder:public Circle
{
public:
Cylinder(double r,double h):Circle(r)
{
height=h;
}

private :
double height;

};

//********************* end ********************

int main()
{
double r,h;
cout<<setiosflags(ios::fixed);
cout<<setprecision(2);
cin>>r;
Circle c(r);
cout<<c.area()<<endl;
cin>>r>>h;
Cylinder cy(r,h);
cout<<cy.area()<<" "<<cy.volume()<<endl;
return 0;
}

``````