|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
u$ P: L! A5 O# U(number : integer)
5 Z4 y% M- ]) S: qis9 X9 I& f% s6 U t
do9 {, k9 J, a* h K P3 H
inspect number
. x) N( j( {3 B when 1 then
3 j! G/ P1 q R, S print "not a prime number"5 q6 i7 x1 e: ]$ i6 }! T
when 2,5,7,3 then
. `. W& J9 V3 P% Q7 x4 E2 h% v+ y- W print "prime number"7 }! j& u8 Y) B* l- h. [
when 9,4 then + ]# ~6 O, T. |+ Z. d% k9 \4 ^( y' k) |& ?
print "square number"6 A3 |! f! m s- ~
else
3 V# C6 M) e3 f, n print "no special number";1 Q D/ x' y4 X& H1 [
print "or number greater than 9";
; x7 N+ q; F7 ^) |6 L) c end;
2 e( p, w# Z+ ?" z! Cend; |
|