设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8143|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
6 y- l" l2 J/ m+ o4 i       Ci :integer; qi : integer* U8 o7 [6 c: z1 U2 }
do " c1 t  P2 P, G. q6 a
       inspect Ci. S0 B- F* k! B$ u5 _
when Ci>0 and Ci <=150 then * ]8 ^' y+ O8 |- P9 u' ?, S+ P
       print qi=1;
( I8 q2 I5 a1 D' L$ l, w3 nwhen Ci>151 and Ci<=500 then
; ]" R5 x7 A+ f6 P- f2 u$ Q) z       print qi=2;3 c. Y4 q  s4 w3 M
when Ci>501 and Ci<=700 then/ {2 U6 {4 x- v  J5 ?
       print qi=3;
: n7 C* g( Q) r& _when Ci>701 and Ci<=1000 then) C4 F* S$ u9 ~1 A. d, o) x
       print qi=4;: J  q6 w* v' S& r( I8 z3 b) h
when Ci>1001 and Ci<=2000 then
0 }- t2 x- n7 U  L' l; L6 e       print qi=5;
( X, w0 }2 p/ g0 j$ f  p0 H/ Owhen Ci>2000 then& |, x% ?! [' W& x$ w4 V0 u2 y. D  d
       print qi=6
/ x: z1 U, ^5 j, Bend;' `" x- ^" }( v7 T7 P+ \
end;
8 b8 K' S+ Z9 z; q# r* J% D$ [5 k; c1 Q" n
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
( W( ~  L* Q# A7 T1 l; t& C! ?          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
+ K& i* o# [" S1 t/ b2 h(number : integer)
- H, W* ]% E+ i( r# A8 Y: jis/ S: G! h5 k. J
do$ {3 k. L, x6 K# j! p. {
   inspect number
% i! X% j6 @9 J" z- l; k2 w' J       when 1 then
' j+ x  u9 H  Z2 n          print "not a prime number"4 ^8 A7 {9 E# O6 m( U+ E+ Z4 c( f* Z
       when 2,5,7,3 then & g  t* q+ }; L7 `
          print "prime number"- W% o0 p: z) Q+ M
       when 9,4 then % R0 n2 \6 v0 T" Q
          print "square number"
! d" Y# l$ [( O$ |: p' V; A0 b       else8 o! F7 Q  A; o7 H$ v) a$ `
          print "no special number";
9 F5 ^1 w5 {+ X0 Z( F. }% i          print "or number greater than 9";% x; B1 d* J  C" B
   end;
/ u+ \' q% j0 G9 J# V% f+ `5 Yend;
 楼主| 发表于 2009-5-13 10:00:51 | 显示全部楼层
我在做一个集装箱码头泊位—岸桥分配的仿真优化模型,我是新手,有很多问题需要请教,高手liysunny能否帮忙,我的qq:540966007。谢谢!!!
发表于 2009-5-13 17:55:54 | 显示全部楼层
发表于 2009-9-15 10:16:40 | 显示全部楼层
楼主Ci没有赋值,应先赋值,再判断
发表于 2010-10-19 09:44:36 | 显示全部楼层
二楼说得很对啊,版主为啥没给加分呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2026-3-26 15:55 , Processed in 0.018394 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表