|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
5 d9 W: R+ J1 s% N: r% T* e! M4 g(number : integer)" U8 u. G. r7 G3 u. `
is
1 |* W( t7 j4 h% ^! ?do
! w( m4 d0 w `+ l% A inspect number, t$ u! K5 X: u9 Y- ~: |
when 1 then
9 ^2 L4 i* ?( n3 T! c% b# m, v" } print "not a prime number"
7 s) i( B1 b G- ^' Z! W6 s when 2,5,7,3 then
9 T" K7 Y5 i' N print "prime number": K: r0 X( C; ^, f
when 9,4 then ; S/ {/ r: A) I' n2 O( }; d
print "square number"! M$ ]5 f: D0 W6 B, {7 t
else
{3 c7 g' C2 G$ j5 y print "no special number";
C8 h4 ]" l; G+ m7 Y+ H& q4 N4 [ print "or number greater than 9";9 }" K7 K1 E2 t
end;
" J$ s w% `7 @- Z" O& G9 cend; |
|