设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8986|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is. t- t% _4 ^; M; a6 `, n' i+ E
       Ci :integer; qi : integer! X# B- [' ?. I7 S, B
do . S8 s% S0 g0 b# b
       inspect Ci
! h) m' ~8 o' m* v  cwhen Ci>0 and Ci <=150 then 4 f7 r7 w9 L! D5 V. }1 @; C' N
       print qi=1;; Y# N: n3 }# J$ I6 ?7 W
when Ci>151 and Ci<=500 then
  I$ d: Y1 E& P) ~       print qi=2;
5 H& D& D; n  f7 ^when Ci>501 and Ci<=700 then. {; h0 L$ {  [7 l9 A, R4 W; S
       print qi=3;
. ?& {! D( _+ ]5 F- Y9 Pwhen Ci>701 and Ci<=1000 then/ z0 p/ M$ H; c/ T: ]
       print qi=4;) f0 V4 X, l+ j0 c, d0 u
when Ci>1001 and Ci<=2000 then
1 x- }8 f$ T1 e, e& q       print qi=5;, R9 u: H% }# j* r
when Ci>2000 then
9 y+ F1 T% q0 h( e# ?       print qi=6
' b# ?2 j% {$ G$ Lend;
3 k) w! {- L' \5 iend;1 R8 T- ]1 |! A

! x3 k: |) r( p          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
+ s( R$ s6 W; s; x" z, C* X, Y: z/ ]          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
5 {, ]; T3 h' z5 Q(number : integer)4 u: [" h# g# \4 F
is+ H, I; o8 v' V( N, q) m" a3 K
do
3 U4 C  G( v4 [7 Z) j   inspect number0 c. x+ O. v  i# L$ _) X
       when 1 then $ e5 n( y+ G# x+ }/ y: u
          print "not a prime number"
# }  M+ u, u& i' \1 K       when 2,5,7,3 then
: e* W- f' h, I9 y  [* _0 g          print "prime number"
! B+ J: d6 P9 J3 g/ z. l$ _  J       when 9,4 then
2 s( t3 ^+ S8 c+ h+ a$ V$ |          print "square number"
6 W0 H4 g1 u% f) U9 I; _7 s" r       else
/ |" R. X3 |! U& N. m' c6 x$ [          print "no special number";
. N+ L, z- g. v. c3 D          print "or number greater than 9";- Z; v; W0 d6 k  Z0 ]+ e( |
   end;4 |3 [) R/ P( [1 ]9 w, }( K; ?
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-7-20 11:48 , Processed in 0.012899 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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