|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:6 `( c2 M, E* r& G- V* Z
(number : integer)( {6 b( l- I2 g' \! \: f& X
is# y7 x+ Z$ o: I; @/ H
do
5 Q' Q' z/ S9 F# H% x I8 D! I inspect number
5 A8 f: S, @5 V- E" i; S0 U when 1 then
% [$ }; t- Q, ^+ L' ? print "not a prime number"
7 K$ N8 M! _. q' e) m when 2,5,7,3 then # t' s5 k) _% ?1 q3 |
print "prime number"! Z. v3 _" e6 S2 y8 L
when 9,4 then
0 i- Q) m' n: \# N- u print "square number": f7 U* ]: x# R5 \
else+ s! |0 V' r* {! Z0 I
print "no special number";) `$ D) h# j0 S0 z, N
print "or number greater than 9";
+ ]5 o8 B8 E: {/ W end;- m; K6 h* I8 t4 J, \6 M
end; |
|