C语言编程题,求大神解,感谢!

如题所述

#include <stdio.h>
int main()
{ double x,y;
scanf("%lf",&x);
if(x==-3||x==2||x==3||x>=10)y=x*x-x-15;
else if(x>=0)y=x*x-5*x+6;
else y=x*x+2*x-6;
printf("%g\n",y);
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2020-04-06
    #include <stdio.h>
    int main()
    {
    float x;
    scanf("%f",&x);
    if (x<0&&x!=-3)
    {
    printf("%f",x*x+2*x-6);
    }
    if (x>=0&&x<10&&x!=2&&x!=3)
    {
    printf("%f",x*x-5*x+6);
    }
    if (x==-3||x==2||x==3||x>=10)
    {
    printf("%f",x*x-x-15);
    }
    return 0;
    }
追答

我这里默认x是浮点数,如果有需要可以根据题目更改

第2个回答  2020-04-06
#include<stdio.h>
#include<string.h>
int main()
{
int x,y;
scanf("%d",&x);
if(x<0&&x!=-3)
y=x*x+2*x-6;
if(x>=0&&x<10&&x!=2&&x!=3)
y=x*x-5*x+6;
if(x==-3||x==2||x==3||x>=10)
y=x*x-x-15;
printf("%d",y);
return 0;
}
相似回答