|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:/ b7 _: ?2 _! Z, C5 e7 E
(number : integer)
7 p" |! R, d8 eis
- P% E0 [. Y: l/ _7 ^6 p- A! @+ vdo7 d( o6 _+ O" Y( _$ B
inspect number$ O- {" n+ ?9 G
when 1 then # {7 F) B9 s2 X# W) T
print "not a prime number"
. Y2 z( p/ h& S& t. M1 P when 2,5,7,3 then
* g; h# g3 W t8 ]( @9 ? print "prime number"
% M* G4 \/ v- J$ c! U$ `3 Q: [6 R when 9,4 then K5 Q U3 ^: K# u: Z
print "square number"! _( Q$ B. J4 y' O; e7 l: |
else
- X/ p) a$ }" N+ J" b print "no special number";
e) T) L* h6 r, d) y, q3 F9 d print "or number greater than 9";8 {) V6 \) T7 J* {
end;
u+ C, E9 L% H" {5 M) {! ^' Send; |
|