fork download
  1. #include <stdio.h>
  2. #define PI 3.14159
  3. int main()
  4. {
  5. float r, h;
  6. float circumference, area, sphereSurfaceArea, sphereVolume, cylinderVolume;
  7. printf("请输入圆半径 r:");
  8. scanf("%f", &r);
  9. printf("请输入圆柱高 h:");
  10. scanf("%f", &h);
  11. circumference = 2 * PI * r;
  12. area = PI * r * r;
  13. sphereSurfaceArea = 4 * PI * r * r;
  14. sphereVolume = (4.0 / 3) * PI * r * r * r;
  15. cylinderVolume = PI * r * r * h;
  16. printf("圆周长为:%.2f\n", circumference);
  17. printf("圆面积为:%.2f\n", area);
  18. printf("圆球表面积为:%.2f\n", sphereSurfaceArea);
  19. printf("圆球体积为:%.2f\n", sphereVolume);
  20. printf("圆柱体积为:%.2f\n", cylinderVolume);
  21. return 0;
  22. }
Success #stdin #stdout 0s 5320KB
stdin
1.5
3
stdout
请输入圆半径 r:请输入圆柱高 h:圆周长为:9.42
圆面积为:7.07
圆球表面积为:28.27
圆球体积为:14.14
圆柱体积为:21.21