#include<stdio.h> int main(void) { double x,y; double a(double x); int i,m; double cylinder(double x,double y); /*自定义函数*/
printf("enter m:"); scanf("%d",&m); for(i=0;i<=m;i++){
/*进入循环*/ printf("enter x"); scanf("%lf",&x); if(x<=0){
/*若x<=0,则输出"输入错误,重新输入"*/
printf("输入错误,重新输入"); } else{
/*计算x>0时的情况*/ y=a(x); printf("y=%.3f ",y); } } return 0; } double a(double x) { double y; if(x<=50){ y=0.53*x; }
/*计算x小于50时的电费*/ else{ y=0.53*50+0.05*(x-50); }
/*计算x大于50时的电费*/ printf("y=f(%f)=%.2f ",x,y); return y; }