设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8452|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is; a/ Q( b- `. E2 N1 V5 [
       Ci :integer; qi : integer" i3 D) ^0 D) H4 E8 o9 }
do
# m% H- Z6 {% k$ n9 U       inspect Ci! D- @" }$ A  c: I9 _
when Ci>0 and Ci <=150 then $ {/ U: j& W7 c
       print qi=1;
# l/ y& T$ {+ U9 j8 @when Ci>151 and Ci<=500 then
1 d6 O. z4 s3 H4 c( y% {  B3 l! n       print qi=2;
3 S' S$ \  a; r; W& ]; z: Lwhen Ci>501 and Ci<=700 then% g! F* U+ G" l
       print qi=3;/ h9 I% Z9 p; _, L! d! c
when Ci>701 and Ci<=1000 then5 `6 e$ w9 W1 K! ~% E
       print qi=4;# P  O6 [9 E3 h5 K1 x0 ^
when Ci>1001 and Ci<=2000 then
7 G" q9 c6 r' F8 y* H& t       print qi=5;# }4 x/ P2 b% O/ |
when Ci>2000 then
0 p2 u, B8 _) D) ]  |5 U       print qi=6  G3 ~5 a8 T+ Z+ D6 @
end;: D$ j+ a5 p/ F" N* z; y5 x2 ]
end;6 G$ R" v" N: o3 ~$ P% U6 Y
. {( ^3 Q! P$ j# O, ~& R
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?. V: }1 M4 O6 {. q
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
4 g2 x% M' U7 F% t(number : integer)0 \7 Q% i' v) L2 |8 u6 C  ?6 @9 }
is
2 M7 Z& G; d8 vdo% x$ l1 J( b$ H$ {0 Y. ]
   inspect number
) G4 q# ?$ E0 ^& H) O       when 1 then   F9 V% m+ ^4 @: k+ A; P; U8 d
          print "not a prime number"0 `9 E# X* n2 y2 M) O
       when 2,5,7,3 then
) ^# o3 L: m; k/ _" @          print "prime number"+ x, C" L8 c; l% R. G
       when 9,4 then
/ D8 O7 z  |! M) s& ]0 h9 l! @          print "square number"
. w; \3 w% e! p0 v       else: O8 a) M& s! |# U2 T* c( V8 t2 L
          print "no special number";
" N8 S. @$ }6 P. a* ^" H7 m6 e8 r          print "or number greater than 9";
' Y0 r; x1 D* F5 s& @% T   end;
/ t- t/ v! v& G8 i9 j0 Nend;
 楼主| 发表于 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-4-28 08:29 , Processed in 0.014719 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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