|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:! l% ~, Z- ~9 \0 t5 O
(number : integer)
0 V0 U2 S! [2 ~& D7 j1 n, R7 Xis& Y+ `# T" I S1 c3 t% u
do# g8 i4 U) h9 q
inspect number
' H0 \+ M; S. ]! H! Z" r h when 1 then ! q. e5 h; e9 y! f# c1 h* E, B
print "not a prime number"
/ l& D3 L6 \8 |% S when 2,5,7,3 then
1 W- ?/ k4 f! w" X4 q0 C1 a3 | print "prime number"
. }) i' d9 F# e when 9,4 then
5 M( {7 R% J: x! _: @ print "square number", z% h+ `4 F9 i0 {! Q
else
* G( b7 L, g9 _6 J* d; z4 [ print "no special number";; V: }4 a5 I# K ~
print "or number greater than 9";
- B8 @( J2 W+ v end;9 f- f) M3 X: ~5 {, [
end; |
|