单选题

以下不能实现符号函数y=sgn(x)的程序段是()。

Aif x>0 then y=1 else if x=0 then y=0 else y= -1

Bif x>0 then y=1 else if x<0 then y= -1 else y=0

Cif x>=0 then if x=0 then y=0 else y= -1 else y=1

Dif x<>0 then if x<0 then y= -1 else y= 1 else y=0

正确答案

来源:www.examk.com

答案解析