520zy
#include<stdio.h>
int main()
{
    int i,n;
    double r,v,h;
    double cylinder(double r,double h);
/*自定义函数*/ printf(
"enter n:"); scanf("%d",&n); for(i=1;i<=n;i++){ printf("Enter r and h:\n");
/*进入循环*/
scanf(
"%lf%lf",&r,&h); if((r<=0)||(h<=0)) { printf("输入错误,重新输入"); } /*判断r是否小于0,病输出结果*/
else{ v=cylinder(r,h); printf("V=%.3f\n",v); /*计算其他情况时n个圆柱的面积*/
} }
return 0; } double cylinder(double r,double h) { double result; result=3.1415926*r*r*h; /*计算一个圆柱的面积*/ return result; }

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-07-16
  • 2022-01-21
  • 2021-12-11
  • 2022-01-18
  • 2022-12-23
  • 2022-02-20
  • 2022-01-15
猜你喜欢
  • 2022-02-03
  • 2021-12-19
  • 2021-12-22
  • 2021-12-08
  • 2022-02-15
  • 2021-12-02
  • 2021-12-01
相关资源
相似解决方案