|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
! y6 Y9 X4 H+ }( v9 b4 }4 z(number : integer)- w: [7 ^8 S' }) n$ g$ e
is
: _1 Z7 `3 }( V, vdo. A( f, S2 g* Z/ y4 e
inspect number
3 C: O! B4 ?, A3 \' g when 1 then
3 V4 S9 J" Q, z1 A+ _( C print "not a prime number", R2 u" v, t2 m0 \ Q1 @0 L5 s
when 2,5,7,3 then : n# i' g3 E) P' Q
print "prime number", {! g: x& I! a$ j
when 9,4 then
$ T2 ] }8 V& G) v! k. N1 H+ } print "square number"
+ t4 F0 G/ f/ M6 i' n else/ J2 S7 }& R2 l, A
print "no special number";
* I F9 b1 ?3 X0 | print "or number greater than 9";
5 V5 r/ k8 L& f! q! t end;# o: E1 j6 W) U* N* F8 ?" L
end; |
|