|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
+ R) a& ?1 n$ x# Q# \) R(number : integer)2 N- ]) w4 |- j; h1 X! D- w4 x
is1 P; z3 Y$ g$ r- _
do) _7 j+ }7 L; W7 e; w9 K+ Z
inspect number! J9 k! o$ f* `" d
when 1 then
! T) p" F0 ]9 x3 f- P print "not a prime number"
$ x+ V* F; P0 z% }2 i when 2,5,7,3 then # Z. i$ c! `! R) L
print "prime number"; C! V" `; ?* H* h- y6 ]7 w5 f
when 9,4 then # K+ N8 k7 ^6 m$ Y; Q V
print "square number". i& V4 W2 V8 d5 }$ B" j! Z {! H" q- l
else7 N8 ]9 x" W7 h! K! s0 j( R
print "no special number";* H0 `* V4 Z0 k, Z) a5 A! g
print "or number greater than 9";
+ g) d# V" |/ B. }) u( @ end;
" ~- ]. S* y( E kend; |
|