- #include<iostream>
- using namespace std;
- const float PI=3.1416;
- float fCir_L(float);
- float fCir_S(float);
- int main()
- {
- float r,l,s;
- cout<<"R=";
- cin>>r;
- l=fCir_L(r);
- s=fCir_S(r);
- cout<<"l="<<l<<endl;
- cout<<"s="<<s<<endl;
- system("pause");
- return 0;
- }
- //计算圆的周长
- float fCir_L(float x)
- {
- float z = -1.0;
- if(x>=0.0)
- z=2*PI*x;
- return(z);
- }
- //计算圆的面积
- float fCir_S(float x)
- {
- float z=-1.0;
- if(x>=0.0)
- z=PI*x*x;
- return(z);
- }
- //该片段来自于http://www.codesnippet.cn/detail/280520133634.html
来源: http://www.codesnippet.cn/detail/280520133634.html