|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:3 @ ~7 [0 s' U, `4 A. C! I2 n
(number : integer)
v- w( f6 I. |* d1 N$ o$ l8 h: ois% v5 o% V- U! Q& T: q7 n
do
, a- }& {, t3 c5 r inspect number6 z4 E( r) @/ {- L6 b
when 1 then , l+ s4 P: f, ]2 j
print "not a prime number"+ u' X) s! i$ F9 i
when 2,5,7,3 then 1 s+ K- V( f8 Y5 F/ S# }' K
print "prime number"& V9 A; @% n, U6 c- o0 j
when 9,4 then
o* o: D4 q' y# R( E& V# f. \) n: \ print "square number"
+ @* d1 p9 I" W else8 J c( g4 [ r) D6 c, D+ h3 D
print "no special number";1 e, Q8 M8 V! R+ O5 j6 C
print "or number greater than 9";
" c6 w- H e7 W0 G end;
( F, D( z" C1 a! |end; |
|