附加题1 2题

1

#include<stdio.h>
int main()
{
double x,sum=0,ave;
int i;
for(i=0;i<4;i++)
{
scanf("%lf",&x);
sum=sum+x;

}
ave=(sum/4);
printf("sum=%.1lf,ave=%.1lf ",sum,ave);
return 0;
}

2
#include<stdio.h>
#include<math.h>
int main()
{
double x,y;
printf("Enter x(x>=0): ");
scanf("%lf",&x);
if(x<=50){
y=0.53*x;
}
else if(x>50)
{
y=(0.53+0.05)*x;
}
printf("y=f(%f)=%.2f ",x,y);
return 0;
}

原文地址:https://www.cnblogs.com/jiangchaomin/p/6069485.html