设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8669|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
7 c2 v/ X7 S$ f       Ci :integer; qi : integer( H4 f5 |" g9 y) I" c2 b0 {+ o
do
* v; y2 f& [0 g  H# s( M' J3 c       inspect Ci$ ?. D) T/ k" m. q
when Ci>0 and Ci <=150 then
! J, ?# {* [3 s9 B4 }6 ?       print qi=1;
; ]6 j" G" v" Y6 twhen Ci>151 and Ci<=500 then1 y7 u; J8 o& J0 o5 S$ |
       print qi=2;
: ?8 b; k* ~+ j0 ?when Ci>501 and Ci<=700 then0 X2 h" i) L9 F4 y. m
       print qi=3;
! m+ }9 _7 c/ Z5 u' Zwhen Ci>701 and Ci<=1000 then
1 |1 |2 y. ^6 A8 V1 J! W       print qi=4;
' n* B: u. c# _) kwhen Ci>1001 and Ci<=2000 then0 p: e, K' ^' Z$ O
       print qi=5;/ |" E4 W- [: q! A
when Ci>2000 then2 ?8 p8 i- l7 \9 ~0 Y0 {
       print qi=6' e8 X$ J8 _6 Y. D9 @
end;
) Q( T4 G& ?9 g# h  nend;2 z! |: d% J$ e+ v6 a: n
  z# `: l7 X; r# {2 Q
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?4 u5 o* J2 `/ Y; |; S) h3 v
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
1 C0 o* B# D( B(number : integer)
7 j3 d) w3 d; \# X; q- Vis) K1 t1 \  b$ M: N% Z
do
2 g" _6 S0 S4 w  m3 L   inspect number8 P% a$ p/ O  |
       when 1 then
. m8 _+ f2 c/ a& n          print "not a prime number"
. i9 {0 w; Z" U; w% K       when 2,5,7,3 then ) q" s7 u1 l6 Z" t
          print "prime number"+ M" N/ s" @" c# k+ P; b" M
       when 9,4 then + v) m3 N# \2 h& @, [& w1 ^
          print "square number"
. y9 q% u" m* g5 V       else
; N# d$ u& m7 U% ~4 i$ s9 G          print "no special number";
1 \) ^9 d- q& w' c# T          print "or number greater than 9";
# ~9 Z7 C: l0 Z; u   end;- Y( O0 f: d$ K9 P/ f
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-6-3 03:11 , Processed in 0.011918 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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