> 其他 >
编程题 计算分段函数sign(x)的值
y=sign(x)=-1 x
人气:456 ℃ 时间:2019-12-01 13:01:52
解答
double 是双精度的浮点型数据,输出使用 %lf格式声明.
另外如果为了减少程序执行多分支流程,建议 swich case 进行分支处理,这样可以只走一个分支,而不是你现在的走三个if 分支.
switch ( ) {
case this-value:
Code to execute if == this-value
break;
case that-value:
Code to execute if == that-value
break;
...
default:
Code to execute if does not equal the value following any of the cases
break;
}
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版