作业帮 > 综合 > 作业

根据以下的函数关系,输入X,计算并输出Y的值

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/10/06 12:28:35
根据以下的函数关系,输入X,计算并输出Y的值
0 x<0
y= x 0≤x<10
10 10≤x<20
-0.5x+20 20≤x<40
#include
main()
{
double x,y;
scanf("%d",&x);
if(x
根据以下的函数关系,输入X,计算并输出Y的值
#include <stdio.h>
main()
{
 double x,y;
 scanf("%lf",&x);    //读取double要用%lf
 if(x<0)
  y=0;
 else if(x<10)
  y=x;
 else if(x<20)
  y=10;
 else if(x<40)    //这里少一个if
  y=-0.5*x+20;
 printf("y=%lf\n",y);    //输出double要用%lf
}