#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: "); scanf("%lf%lf",&r,&h); if((r>0)&&(h>0)) { v=cylinder(r,h); printf("V=%.2f ",v); } else{ printf("输入错误,重新输入"); } } return 0; } double cylinder(double r,double h) { double result; result=3.14*r*r*h; return result; }