#include<stdio.h> int main() { int n,i; double r,h,v; double cylinder(double r,double h); v=cylinder(r,h); printf("输入n="); scanf("%d",&n); for(i=1;i<=n;i++){ printf("输入h,r="); scanf("%lf%lf",&h,&r); if((r<=0)||(h<=0)){ printf("输入错误\n"); } else { v=3.14*r*r*h; printf("v=%.3f\n",v); } } return 0; } double cylinder(double r,double h) { double result; result=3.14*r*r*h; return result; }