|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:6 K; @2 P ^& R Q
(number : integer)
) q1 d6 b! k, N; h% kis7 p! [5 h z2 ?" j% k
do! i+ N( B3 b' S
inspect number
' o t& x {( D, l9 O* Q7 U) d6 ~+ }# v" [ when 1 then 2 G/ A1 e. l5 B: Y8 Q
print "not a prime number"3 w; d: K: \) ^ A. c: U
when 2,5,7,3 then / D# V& j3 `3 |$ z" O# B' a; w
print "prime number"
! S8 j0 d# o* |( K* z+ L when 9,4 then
) a4 B ?7 `% K7 w! K print "square number"
% v" P. [6 z5 ` else
" A, s- I$ T/ x+ F" H8 \0 [ print "no special number";" o3 }. u/ U& w, r3 o
print "or number greater than 9";, Z) m7 S* M/ v8 S+ y, I& [+ l
end;/ @# R7 m6 w; [6 M9 \
end; |
|