|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:& k# z( k! B2 M0 [
(number : integer): {; D* L& U& {0 |/ z# N8 l
is8 }0 O$ w% q7 T7 l
do
" x( x5 B- y9 ?- z& B; J inspect number; W. F- |/ w& T R% N- ?
when 1 then ! a; V* N( |3 \4 y e' S, N3 T
print "not a prime number"$ T: v; B1 R8 n5 L1 W3 Y- F9 P
when 2,5,7,3 then & T& h1 g" v) c" P1 C, o
print "prime number"% i- l L5 J3 ]4 Y
when 9,4 then / L' u. C3 _2 [, P' g5 x
print "square number": T! Z) c4 O- g+ ^9 K! a
else
/ e6 ?3 L3 l$ J M print "no special number";
, O: w+ a8 I+ k" e; W m print "or number greater than 9";
5 ?- F* P% ~. }: B& g9 C end;; J4 i( [, U# ]# V; M/ S. |
end; |
|