|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
1 L7 g/ k; V% [- s(number : integer)5 D* c0 l9 C0 N7 I3 p% w
is
" a7 m3 g( v. b4 L; B$ k- Z0 tdo% w3 V- p: V' w. q. _% Y0 U
inspect number
0 Q g% s Q- b1 X) L when 1 then
9 f7 M* |; x* v, R print "not a prime number"; l, M+ d/ h% l0 x: T. _9 q
when 2,5,7,3 then
+ j* L$ \6 Z ~ |5 r( M& i4 V print "prime number"
( O* D8 U8 h' \% W% W when 9,4 then & e$ u* _! X% G$ g) d' T3 y
print "square number"
$ M8 v8 n" c5 m) l4 e7 h4 q else
" t! Z& ?, Q+ G# w; x% { print "no special number";( Z/ w3 A# z6 m: @
print "or number greater than 9";: |; J& h: q* ` a& c
end;
6 [& I. r9 e# {5 G% Send; |
|