第3週任務2:干ばつの氷場を修理する

1215 ワード

/*   
*                
* Copyright (c)2013,               
* All rightsreserved.   
*     :1.cpp                              
*       :                                  
*     : 2013   03   15     
*    : v1.0         
*     :         ,     
*     :     main    ,          
*/ 
#include<iostream>
using namespace std;     
class Circle
{
public:
	void setRadius(double r);
	double area();
	double circumference();
private:
	double radius;
};
void Circle::setRadius(double r)
{
	radius=r;
}
double Circle::area ()
{
	double PI=3.14,area=0;
	area=PI*radius*radius;
	return area;
}
double Circle::circumference()
{
	double PI=3.14,circumference=0;
	circumference=PI*2*radius;
	return circumference;
}
int main()
{	double r;
	cout<<"         : ";
	cin>>r;
	Circle c;
	c.setRadius(r);
	cout<<"        "<<20*c.area()+35*c.circumference()<<"  。"<<endl;
	return 0;
}

実行結果: