|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:1 q2 |3 S! }, R2 U; K
(number : integer)
8 G# g5 Y3 }" T9 s5 Q$ U; ais4 c) l; H* m) U3 o4 \
do) N, h6 ?7 L! V5 v I# q& D( |1 W
inspect number
" A. N0 b! ^4 v: D% ]3 z when 1 then 5 Y. t' H I: c! X
print "not a prime number"* ~4 Q" u+ ~0 t. b5 W
when 2,5,7,3 then 5 S) ]7 r/ Z3 u. h6 ^7 m8 A& @/ S( _
print "prime number"7 S# _2 I/ ~7 m( m. p# h, x+ b$ I7 y
when 9,4 then
) C! v0 x* q$ O$ _ print "square number"
0 u$ ]/ f* y; |- X, c2 \) ^1 R& Y else4 T9 x* `3 S- j0 m$ R) ~2 I
print "no special number";
$ p* C) S8 W4 Y$ J- t- B print "or number greater than 9";+ Y2 N: V: s9 h* q3 I. b
end;5 ^6 h E5 Y8 r, w4 f/ [( j
end; |
|