设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8123|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
; U- r2 |$ W# z! ?; u  W       Ci :integer; qi : integer5 z5 {. \$ V$ m6 A
do
; O$ `9 L5 s2 I       inspect Ci0 k: \8 H$ g. d) d# a
when Ci>0 and Ci <=150 then " A0 p$ [) j) C9 I
       print qi=1;0 g, `/ B, Z% O, }
when Ci>151 and Ci<=500 then! q, X( x" L( {1 O4 k4 v
       print qi=2;
5 Z/ K, j8 T& [9 N/ Xwhen Ci>501 and Ci<=700 then% `! e4 J; V+ u+ L" Q
       print qi=3;
# {& i' M& h" X4 e+ I" @" a1 ewhen Ci>701 and Ci<=1000 then+ L- \& o- K' h$ l  G
       print qi=4;
) T: m1 }. R1 l* Y: k) Y. Jwhen Ci>1001 and Ci<=2000 then1 W1 |/ u% Q2 H" Y" y
       print qi=5;
/ R3 y9 }; K6 f5 ?# e$ twhen Ci>2000 then9 J: w2 v+ @2 g0 @. b5 a+ T
       print qi=6
& k  i. v2 L& l, f+ N6 H7 I* vend;; H2 O- f: B( S2 R  f0 I
end;
& [1 x% K' u) L8 U: E7 M, V; q4 |1 q+ ~2 Z0 ]
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?" y  L4 B* C: `
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:5 Y0 L% K0 J' F* d
(number : integer)+ z# V' B/ a* y! i
is4 e' `: z9 s" m1 d2 a/ F
do
' b8 O+ v7 A4 g, u, r; k' p   inspect number
, i9 m* g6 g0 R7 t  f       when 1 then " y  Z; N( e' ]# }. m+ o
          print "not a prime number"
1 v+ @3 w: l) W) A       when 2,5,7,3 then + c1 A4 v0 @* D7 |3 L) B) ]9 w
          print "prime number"
% h/ a' v% p8 B2 G& w# O       when 9,4 then
8 S, P+ v! |  h* i7 D& a% ]          print "square number"  L+ d8 w* k1 k2 N1 V8 S+ G; \' U
       else
* v$ F# t7 h) j/ f7 ~0 M          print "no special number";, H& Z' a' I# ]1 u+ I
          print "or number greater than 9";
" h, {3 R- R. z+ |# ?4 S4 [$ Z6 {   end;2 r4 V& f! a5 O& D6 v1 g5 c
end;
 楼主| 发表于 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-24 05:08 , Processed in 0.015408 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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