|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:1 Q3 L: x+ p, |7 M2 ^6 O; h# }
(number : integer)
5 V5 v, b9 J, C/ Z0 l lis
, B/ S. S; V) k, C% E( u! ~do$ Y' C4 G# Q) Y+ {: `. Y
inspect number- k% h- w9 q' c1 @1 f0 g
when 1 then
3 }2 A9 Y4 D% `% ` print "not a prime number"
+ j0 c" B% _: W/ n8 w- |6 ` when 2,5,7,3 then : e. ]! j- B/ @& g& Y( w
print "prime number"0 O9 ?+ e ~# F- q
when 9,4 then 5 {# `! u0 t. d" M2 |
print "square number"
% b. ?9 Y; b+ N else
% K$ z4 y; [9 S: R; W: j print "no special number";- n5 Z+ }1 |. s2 \4 W( K1 O
print "or number greater than 9";# Q$ ?+ O% E0 G6 V5 N
end;5 y/ Q; m+ _' @& H0 S) |
end; |
|