附加题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\n",sum,ave);
return 0;
}

2
#include<stdio.h>
#include<math.h>
int main()
{
double x,y;
printf("Enter x(x>=0):\n");
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\n",x,y);
return 0;
}

 

posted @ 2016-11-16 14:45  江超民  阅读(135)  评论(1编辑  收藏  举报