“21天好习惯”第一期——9_qq
用C语言表示分段函数
#include "stdio.h" #include "math.h" int main(int argc,char *argv[]){ double x,y; printf("Input x(R:)... x="); scanf("%%lf",&x); if(x<5) y=-x+3.5; else if(x>=5 && x<10) y=20-3.5*pow(x+3,7);//这里看着像7,是几就把7改成几 else y=-3.5+sin(x); printf("y = %%g (x==%%g) ",y,x); return 0; }
推荐阅读