|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:3 Y' Q2 ?% R" S y& n+ v, w+ `
(number : integer)
5 ?0 ^$ u% v; H$ X0 C0 O: B! l% fis/ t; U& A. H5 `' `) N' e
do
6 C; \0 q" @: t9 U" b inspect number
& I6 }. w/ s7 b when 1 then ; T* j4 @) }9 g
print "not a prime number"
! x0 U1 Y Q5 n; E8 m( R2 f/ ^ when 2,5,7,3 then
4 H8 L3 v: H: r* O" U. J print "prime number"
; z, a( s- n' G" p" |. f9 V+ B when 9,4 then
5 p/ ]6 ^3 z; f5 |2 A$ S; A j print "square number"3 M! Z" P3 M, D c6 a+ X. _' L
else
2 x7 s7 B% Q. C* ?6 ~ }3 p: e print "no special number";
; K) b8 r; k) ^2 G/ t$ k1 _ print "or number greater than 9";
9 M3 [6 G: |3 v9 W% n* A1 U end;
0 Z7 T1 D {, e3 x P. L7 |end; |
|