作者在 2014-04-16 23:16:40 发布以下内容
#include <iostream>
const double PI=3.14;
using namespace std;
double fcir_l(double r)
{
double cir_l;
cir_l=2*PI*r;
return cir_l;
}
double fcir_s(double r)
{
double cir_s;
cir_s=PI*r*r;
return cir_s;
}
int main()
{
double radius, cir_l,cir_s;
int i=0;
cout<<"Please input radius:"<<endl;
cin>>radius;
cout<<"please choose number:1.perimeter 2.area"<<endl;
cin>>i;
switch(i)
{
case 1:
cir_l=fcir_l(radius);
cout<<"the perimeter is:"<<cir_l<<endl;
break;
case 2:
cir_s=fcir_s(radius);
cout<<"the area is:"<<cir_s<<endl;
break;
}
return 0;
}