單項選擇題

以下不能實(shí)現(xiàn)符號函數(shù)y=sgn(x)的程序段是()。

A.if x>0 then y=1 else if x=0 then y=0 else y= -1
B.if x>0 then y=1 else if x<0 then y= -1 else y=0
C.if x>=0 then if x=0 then y=0 else y= -1 else y=1
D.if x<>0 then if x<0 then y= -1 else y= 1 else y=0

微信掃碼免費(fèi)搜題