|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
& V- Y- C4 i. s n @(number : integer)
, W2 K" m1 }2 _6 |4 lis5 r) K' S, M+ m8 a! J* W
do% p1 n0 e9 s! m) ~9 M b0 a7 s6 @
inspect number
1 m, [8 S" P$ V0 x" i0 o8 Z when 1 then ; M J+ B; d3 G3 a
print "not a prime number"
@7 M0 j# T) a+ W. p) G when 2,5,7,3 then 8 V% ~6 e/ c# z
print "prime number"
4 N. w$ P9 h' b- e/ M when 9,4 then
, e) H! A% R- f print "square number"! Y! V- J; E! C" Z6 o$ h
else9 V0 _6 k3 b2 }5 N0 w% k
print "no special number";
2 N# E# M: P m* ~1 \ print "or number greater than 9";* Q4 Z; ^* U. c+ r
end;' F- ?2 y% P% E4 g. @& y1 x
end; |
|