#include<stdio.h>
int main(void)
{
    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("输入错误,重新输入");
        }
        else{
            v=cylinder(r,h);
            printf("V=%.3f\n",v);
        }
    }

    return 0;
}
double cylinder(double r,double h)
{
    double result;
    result=3.1415926*r*r*h;
    
    return result;
}

 

#include<stdio.h>
int main(void)
{
    int i,n;
    double s,r;
    
    printf("enter n:");
    scanf("%d",&n);

    for(i=1;i<=n;i++){
        printf("Enter r:");
        scanf("%lf",&r);
        if(r<=0){
            printf("输入错误,重新输入");
        return 0;
        }

        else if(r<=50){

            s=r*0.53;
            printf("s=%.3f\n",s);
        }
    
        else{

            s=50*0.53+(r-50)*0.58;
            printf("s=%.3f\n",s);
        }
    }

    return 0;
}