实验4-1 求花费电费的金额

#include<stdio.h>
int main(void)
{
    int i,n;
    double x,y;
    printf("The enter n:");
    scanf("%d",&n);
    for(i=1;i<n;i++){
        printf("The enter x:");
        scanf("%lf",&x);
        if(x<=0){
            printf("The enter is wrong");
        }
            if(x<=50){
                y=0.53*x;
            printf("y=%.2f\n",y);
            }
            if (x>50){
                y=0.53*50+(x-50)*0.58;
            printf("y=%.2f\n",y);
    }
    }
        return 0;
}

 

posted @ 2013-10-17 11:24  韵文  阅读(131)  评论(0编辑  收藏  举报