|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:+ w" h9 K2 l- a! |# f
(number : integer)4 M$ B; s; T. o' {
is
/ P# V3 Z, w& L7 C% [% {4 |do' q8 R( d; C: W0 X7 g
inspect number5 E7 R' F+ M; Q4 K* ^! c
when 1 then
* c& C' |( _" x- B print "not a prime number"8 q4 {( p+ X2 [ H, ~) _
when 2,5,7,3 then
7 i {; L/ y" m3 j+ X" } print "prime number"5 B+ `- H2 Y1 [, `
when 9,4 then ) S8 n& u+ }" y2 ~
print "square number"5 b0 H) ~! x% t* L C5 i
else9 Q \( ^! d4 u& z; i# {) ~
print "no special number";
B+ y: w+ y3 t/ e/ X8 m( h% T print "or number greater than 9";# C( E' H# k2 c, ~% d" z
end;3 G9 v& K+ m2 H& D. p
end; |
|