|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:$ `: y1 u: Q1 O6 `$ {0 j
(number : integer)
" Q/ F, p! F% |2 y# ], n( Gis. g% s: ]$ E% C, @1 n
do+ ]% S8 @, L+ M3 P* R& V
inspect number7 N9 K- @( c3 U: L7 w9 I1 D8 H
when 1 then 4 s: @9 l5 P% f, C5 O( ^
print "not a prime number". m5 e6 a" _5 W3 H: T
when 2,5,7,3 then
+ D7 V! P% y, F: J. w8 N: S8 R/ I ] print "prime number"- \, f/ @( o1 B% W6 h. v" e
when 9,4 then
! S4 W: e: e [/ i* h$ P- R, S0 l print "square number"0 v5 U, h9 _4 K# j5 L: q/ o3 |
else
" G8 t2 v2 V" o) @9 t6 C print "no special number";
y) U3 o6 L. X6 Z print "or number greater than 9";# c1 t5 U# ~3 T/ \6 \8 V9 q7 u% n
end;
- K4 T5 B4 C) J7 M+ Q/ uend; |
|