一个小程序,不知道哪里错了?

来源:百度知道 编辑:UC知道 时间:2024/05/30 13:13:01
#include "stdio.h"
#include "math.h"
main()
{
int x,y;
if (x<=-10)
y=2*x;
else if (-10<x<=0)
y=2+x;
else if (0<x<=10)
y=x-2;
else (x>10)
y=x/10;
}
#include "stdio.h"
#include "math.h"
main()
{
int x,y;
if (x<=-10)
y=2*x;
else if (-10<x&&x<=0)
y=2+x;
else if (0<x&&x<=10)
y=x-2;
else
y=x/10
}
改成这样还是不对啊

#include "stdio.h"
#include "math.h"
main()
{
int x,y;
if (x<=-10)
y=2*x;
//else if (-10<x<=0)
else if (-10<x && x<=0)
y=2+x;
//else if (0<x<=10)
else if (0<x && x<=10)

y=x-2;
else (x>10)
y=x/10;
}

LZ基本知识要加强

if判断写错,基础知识不够扎实,建议多看点书

在C中不能写a<x<b的形式判断

没有输入输出函数.那你怎么看啊

“-10<x<=0”不能这么写的,要写成“x>-10&&x<=0”
还有啊,这个好像不能在主函数里只写这些东西。这个程序应该写在成员函数里吧
应该是void jisuan(){程序内容}
再在主函数里调用它吧