C语言判断输入数正负

来源:互联网 发布:帝国cms视频管理系统 编辑:程序博客网 时间:2024/05/18 03:54
#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;}

原创粉丝点击