|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:" u. ~: z* B+ `
(number : integer)$ w& K0 e8 s1 A. B7 ]" p: W
is
' J0 `6 _$ ?5 odo- Y6 [) {- d2 M
inspect number* X, a. c% b6 \% y- i- p2 E0 F
when 1 then
8 P3 c! n* G( {+ h print "not a prime number"
Z* P1 _. ]8 D) ^6 L when 2,5,7,3 then
: W+ K' M3 W' x1 a print "prime number"1 h! {- Y$ F' x6 g: J
when 9,4 then
) e# I) r) M0 Y Q. F6 Y print "square number"
' P! b6 U9 k' m' Q7 ^! p else/ }7 A- e. F$ B0 J1 F. |
print "no special number";4 y( a: i. q; {) H* i2 J ^
print "or number greater than 9";, P5 N0 z( }, A2 ?' G/ x
end;2 I3 r% Y! E9 K7 d/ C8 y
end; |
|