|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
( k# p1 k2 w0 h# e0 h(number : integer)
2 U1 ^+ |7 _4 z! vis; Q2 V; ]# H( l$ V
do2 [8 E3 L3 s4 R7 U
inspect number$ J! [6 i, E; `4 }8 s6 B# b3 T5 Z0 \
when 1 then ! U" M" Q7 E$ y( d: b/ A: v+ B
print "not a prime number"2 D5 U& w$ K+ j t2 S
when 2,5,7,3 then : V2 K N5 J8 d6 J
print "prime number"
* L+ p _- } P- } when 9,4 then
4 T+ M8 r' u$ y print "square number"& i, }- u7 C9 U3 M
else( j; f' f0 Y$ ]) c6 m
print "no special number";: Q" @1 A+ f) Z; S) N
print "or number greater than 9"; C( H6 M* X8 [ V. g
end;% S9 x/ N! n V# {9 h
end; |
|