#include <stdio.h>
int sign( int x );
int main()
{
int x;
scanf("%d", &x);
printf("sign(%d) = %d\n", x, sign(x));
return 0;
}
/* 你的代码将被嵌在这里 */
int sign (int x){
if(x>0)
return 1;
else if(x==0)
return 0;
else return -1;
}
本文介绍了一个使用C语言实现的符号函数(sign function),该函数能够根据输入整数的正负返回1、0或-1。代码包括了主函数用于接收用户输入,并调用sign函数进行判断,最后输出结果。
#include <stdio.h>
int sign( int x );
int main()
{
int x;
scanf("%d", &x);
printf("sign(%d) = %d\n", x, sign(x));
return 0;
}
/* 你的代码将被嵌在这里 */
int sign (int x){
if(x>0)
return 1;
else if(x==0)
return 0;
else return -1;
}
492
155

被折叠的 条评论
为什么被折叠?