|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:. `0 C1 W( Q2 Y9 Q& }" Z
(number : integer)
8 P) f6 D& Z+ N# \$ c" `2 O7 x) Nis8 D, y$ i# j; a% |9 w: t1 Z
do
- @. S8 f" f8 L4 J inspect number) c& ?7 y4 Z/ O" q3 H1 |
when 1 then - S! n* D4 H) ?' `% L
print "not a prime number"
# r% ^1 d. P; p when 2,5,7,3 then
2 f" d( o7 \" q/ x6 c% s& T print "prime number"" W9 n5 B/ Q [* r# L# k
when 9,4 then . O, m8 ~7 F3 M f; U, M7 e
print "square number"
. n ]& e) ~. y0 L$ B else
6 r8 j& J9 k7 Z1 h- C0 v; C. C1 O print "no special number";
7 n4 s7 ? O# V5 y' c* p7 M( ]0 i print "or number greater than 9";
+ c6 K. K# p, U* {/ b( I2 [/ W# j3 L end;) V# b. l) C$ `
end; |
|