c语言sgn函数怎么定义 调用方式
sgn函数的定义如下:
int sgn(int x)
{
if (x > 0)
return 1;
else if (x < 0)
return -1;
else
return 0;
}
调用方式如下:
int result = sgn(10); // result的值为1
int result2 = sgn(-10); // result2的值为-1
int result3 = sgn(0); // result3的值为0
原文地址: https://www.cveoy.top/t/topic/c2b7 著作权归作者所有。请勿转载和采集!