|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
4 n2 v" h/ j$ M/ C1 w( J% ?0 a(number : integer), @" o9 @ ?# U; P
is( [4 _, X, C5 ?* i3 i* {0 p- U- `
do3 c: U# i/ w" X0 q5 Y
inspect number
3 `# [5 T8 \! t# `- a+ \ when 1 then
: E: a( N: M, @6 ~. V* I2 @8 X print "not a prime number". Z! {+ [# c) N3 ~- Z
when 2,5,7,3 then
( M4 ~& X) ^8 C print "prime number"+ [/ S& i( q0 p2 Z
when 9,4 then - c, A, @$ ?+ _8 C
print "square number"5 `5 {1 u* K+ K6 W, Q$ i
else" o9 i4 {4 S7 X0 K6 f2 [
print "no special number";
" S9 H- k. R% p. o% l print "or number greater than 9";! @" O$ c9 S o; ?% {& E' a
end;
3 z0 M2 h3 j s+ v- ]: c2 ` kend; |
|