|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
7 ?, ]5 q, U8 x- v3 o9 c1 w(number : integer), ]$ L$ q1 c% ^0 L( [7 ]% g# u
is
" r& o. }0 I* z; Kdo# N+ Q0 {# A. x1 q- I& q
inspect number" B) k% m- x) E0 c# P
when 1 then 2 V. H$ _; e/ s0 P: u
print "not a prime number"
; Z# w6 ^3 o ^ when 2,5,7,3 then
2 `) J& v5 |) Y! [0 b5 x" [; S& Z print "prime number"( E$ K3 {) Z$ [
when 9,4 then 8 W6 F" L* e: d6 _" \2 X+ U
print "square number"
1 B" U* R/ }, I0 k/ S: n else# K) k' `5 u: O, S0 I0 l. v, h+ r' a, u
print "no special number";
, H/ V% D6 i7 K' c print "or number greater than 9";1 d/ H6 h# @0 v# z' s" {% s
end;
& c9 c7 |: W, kend; |
|