|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:: {$ e9 U& H3 P' |! f. h% {
(number : integer)
- `, W. v u! \! n5 w2 Bis
P. \; i/ c, o7 T* z" f9 Ldo
[: t- l6 |! v0 D inspect number5 O/ O3 J' d! x! f
when 1 then
4 u8 P3 {" @5 l: k print "not a prime number"
0 K3 w9 |+ _6 P6 f2 Q# _/ K* D, @ when 2,5,7,3 then
7 n- w' e# f7 ` print "prime number"
/ H. B( m, \9 L% J9 \( x when 9,4 then
?4 m7 s1 \5 f5 \% T/ q5 U print "square number"
5 r' L5 Y4 V; o6 V1 o else: u/ `, t: v) y, k
print "no special number";
3 y# [! _2 r$ o print "or number greater than 9";
/ [7 Y# i4 Q4 ~/ n- k+ ^ end;, V* Z2 R, F+ u; G
end; |
|