|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
! b8 n# R9 R5 a$ m% T+ B4 p2 T5 `- G(number : integer)9 C% B8 N( n4 ~0 H
is
! g# C& w3 {4 A( p( Y6 Q1 h0 K/ Vdo U0 Q0 d8 a& n8 q5 r; W4 D
inspect number
, S5 F% L' q- ~8 s when 1 then
7 W$ T: F' t, e v$ h0 H$ c9 O print "not a prime number"' \' l Z) R! e; c* e4 l
when 2,5,7,3 then
* [7 ^) ]1 u2 M* T# z4 C3 o print "prime number"
6 [1 [; {5 V+ U+ L2 H; J0 e when 9,4 then
+ t" A4 `6 q4 _0 [ print "square number"$ N C6 G& l# F( Y4 s3 {: ]
else- p" D# K4 k- R! I! S" q
print "no special number";- ?; u: V( E0 e1 H% A
print "or number greater than 9";
4 H- t. Q* L; [ end;+ g! A. E6 }( ^" x0 W
end; |
|