/*计算用户要支付的电费*/ #include<stdio.h> int main(void) { double x,y; printf("Enter x(x>=0): ");/*输入提示*/ scanf("%lf",&x); if(x<=50){/*判断输入的值*/ y=0.53*x; } else{ y=0.53*50+(x-50)*0.58; } printf("y=f(%f)=%.2f ",x,y); return 0; }
/*计算用户要支付的电费*/ #include<stdio.h> int main(void) { double x,y; printf("Enter x(x>=0): ");/*输入提示*/ scanf("%lf",&x); if(x<=50){/*判断输入的值*/ y=0.53*x; } else{ y=0.53*50+(x-50)*0.58; } printf("y=f(%f)=%.2f ",x,y); return 0; }