|
|
发表于 2009-5-12 23:36:09
|
显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:9 A: v0 A& F# n! k: \
(number : integer): \' Q4 k: f4 H. f1 M {' D
is
$ o0 C8 C7 H7 O0 Zdo* o+ T H9 f1 c
inspect number; ?6 B% Z$ ~5 P# l+ T5 \
when 1 then
7 ^* h1 [1 Q" @% A. { print "not a prime number"& X! J) G% c0 E' n
when 2,5,7,3 then . ^# m% K( f. {1 s- m
print "prime number"
; ]# S) E% L+ [3 H, ? when 9,4 then 0 n+ ~9 W I/ z
print "square number": R0 @3 \( G- U/ M# \9 [3 K
else: L( G3 [" E1 o
print "no special number";, z+ k( I3 A9 _4 _
print "or number greater than 9";, M& H2 d* _" x
end;
# t. n+ G" P; ]5 Cend; |
|