计算N户电费

#include
int main(void)
{
    int i,n;
    double x,y;
    double cylinder(double x);

    printf("Enter n:");
    scanf("%d",&n);

    for(i=1;i<=n;i++){
        printf("Enter x :\n");
        scanf("%lf",&x);

        if(x<=0)
        {
            printf("Enter wrong!");
        }
        else{
            y=cylinder(x);
            printf("y=%.3f\n",y);
        }
    }
    return 0;
}
double cylinder(double x)
{
    double y;
    if(x<=50){
        y=0.53*x/3;
    }
    else{
        y=0.58*x-2.5;
    }
    printf("y=f(%f)=%.2f\n",y);

    return y;
}

计算N户电费_第1张图片

转载于:https://www.cnblogs.com/xym0914/p/3373441.html

你可能感兴趣的:(计算N户电费)