|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
- \) H6 m* z% c% n b(number : integer); B2 @5 \7 v8 m6 z
is/ Z* b) c& D/ Y8 O; z
do
9 G8 c, a4 l* T' d inspect number
' j4 Y2 s' U. V/ M- u* }: { when 1 then
- w8 [# h' b* F print "not a prime number"
Y8 B: M- t5 D, Q7 C when 2,5,7,3 then - s1 v, k; h# G; s7 t: \' Y4 {
print "prime number"
1 q1 D' Q* W6 y, r3 }" f when 9,4 then
; l" b6 \8 y* ?: B2 e print "square number"
2 }; h* ^, v; X: H/ y else0 q* t( i: |2 M' K" W, M- p0 j
print "no special number";6 N5 l$ p3 a1 V" O' S, u7 U
print "or number greater than 9";' R( a. ~" W1 z
end;' m/ J$ {5 X2 `. ~ Z
end; |
|