|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:/ S5 D+ ~* x }$ R) j8 B8 q
(number : integer)+ u( R# c. o- c; e: A3 q7 p
is7 t6 ?4 P1 W; p% m: M
do/ f4 c3 `, W. W% A# j
inspect number3 ? b, n) p7 t" ~/ |% E3 A# C
when 1 then ! \6 L6 H, {/ ]
print "not a prime number"
7 o3 h* d/ Z; _8 s when 2,5,7,3 then : c% q) Z% e4 x& d/ N1 `4 P* Q
print "prime number"
9 `4 |* H7 m( N$ s$ n) ^# u6 s when 9,4 then - z2 P9 p0 p/ N8 K7 ?
print "square number"
; s# _0 g! y1 @* @0 W# [( C7 a" V else# w0 [1 m) z& Q5 o3 f: W
print "no special number";
- C# h( {2 C0 i& g+ |5 o. _ y print "or number greater than 9";
% R/ `* R P2 L8 M end;
2 E9 P6 p# f% P- F- K- w: S2 @7 @end; |
|