#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int shu1,shu2;
printf("请输入需要判断的数:");
scanf("%d",&shu1);
if(shu1>0)
{
shu2=1;
}
else if(shu1==0)
{
shu2=0;
}
else if(shu1<0)
{
shu2=-1;
}
printf("输出\n-1,则小于0;\n0,则等于0;\n1则大于0;\n输出为:%d",shu2);
return 0;
}
C语言判断输入数正负
最新推荐文章于 2025-03-24 13:19:28 发布