1103: 零起點學算法10——求圓柱體的表面積
Time Limit: 1 Sec Memory Limit: 128 MB 64bit IO Format: %lldSubmitted: 11616 Accepted: 1956
[Submit][Status][Web Board]
Description
很簡單的問題,求圓柱體的表面積
Input
多組測試數據,每組輸入底面半徑r和高h
Output
每組輸出圓柱體的表面積,保留3位小數
Sample Input 
3.5 9
Sample Output
Area=274.889
HINT
注意:pi的計算為:const double pi=4.0 * atan(1.0);
Source
1 #include<stdio.h> 2 #include<math.h> 3 const double pi=4.0 * atan(1.0); 4 int main () 5 { 6 double r,h,s1,s2,s; 7 while(scanf("%lf%lf", &r , &h)!=EOF) 8 {s1=pi*r*r; 9 s2=2*pi*r*h; 10 printf("Area=%.3lf\n",s=2.0*s1+s2);} 11 return 0; 12 }
