|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
5 {, ]; T3 h' z5 Q(number : integer)4 u: [" h# g# \4 F
is+ H, I; o8 v' V( N, q) m" a3 K
do
3 U4 C G( v4 [7 Z) j inspect number0 c. x+ O. v i# L$ _) X
when 1 then $ e5 n( y+ G# x+ }/ y: u
print "not a prime number"
# } M+ u, u& i' \1 K when 2,5,7,3 then
: e* W- f' h, I9 y [* _0 g print "prime number"
! B+ J: d6 P9 J3 g/ z. l$ _ J when 9,4 then
2 s( t3 ^+ S8 c+ h+ a$ V$ | print "square number"
6 W0 H4 g1 u% f) U9 I; _7 s" r else
/ |" R. X3 |! U& N. m' c6 x$ [ print "no special number";
. N+ L, z- g. v. c3 D print "or number greater than 9";- Z; v; W0 d6 k Z0 ]+ e( |
end;4 |3 [) R/ P( [1 ]9 w, }( K; ?
end; |
|