“需要逻辑0或非0在main()函数中”是啥意思

来源:百度知道 编辑:UC知道 时间:2024/05/22 16:07:22
不用逻辑运算,表示x<=3且x>=1且y<=3且y>=1。我这样写
#include<stdio.h>
main()
{float x,y;
printf("input x,y:\n");
scanf("%f%f",&x,&y);
if((fabs(x)>3.0)+(fabs(x)<1.0)+(fabs(y)>3.0)+(fabs(y)<1.0)=0)
printf("OK!\n");
else
printf("Error!\n");
getch();
}
但错误提示需要逻辑0或非0在main()函数中,为什么?应该怎么改?

#include<stdio.h>
#include<math.h>
main(){int n=0;
double m,x,f;
scanf("%f",&x);
while(x!=0)f=fabs(x)/x;
while(fabs(x)<0.1)
{fabs(x)*=10;n--;m=f*fabs(x);}
while(fabs(x)>=1){fabs(x)/=10;n++;m=f*fabs(x);}
printf("%fe%d\n",m,n);getch();}

目的是为了把一个实数用指数形式输出

#include<stdio.h>
#include<math.h>
void main()
{float x,y;
printf("input x,y:\n");
scanf("%f,%f",&x,&y);
if((fabs(x)>3.0)+(fabs(x)<1.0)+(fabs(y)>3.0)+(fabs(y)<1.0)==0)
printf("OK!\n");
else
printf("Error!\n");
}

你的程序错误较多,所以我重新写的,经编译通过……0 error(s), 0 warning(s)
主要应该用==而不是=。
要分清