设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9477|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
: q8 f: g) T/ R$ X+ I2 l       Ci :integer; qi : integer
/ \1 W( n" v5 ^: |1 m& N% Kdo 1 r9 T  f2 V! _) P% A2 L; n
       inspect Ci
3 g" C% P+ e6 a5 \/ d2 ~& e/ twhen Ci>0 and Ci <=150 then : g4 X6 s" ~7 d0 C
       print qi=1;
+ m! g: r, F8 `* j- cwhen Ci>151 and Ci<=500 then3 O9 U1 P* k  J7 ]3 J5 Q. x+ O1 m$ x
       print qi=2;
2 E: c7 K3 T/ f% c5 i' swhen Ci>501 and Ci<=700 then# d; L% N. m0 p; Z/ U6 k2 e! J( r% i
       print qi=3;3 U' Z7 H( n5 Y: `* |
when Ci>701 and Ci<=1000 then$ Y/ [1 a" Y2 L! w) c8 ?9 d
       print qi=4;/ `. u9 x4 {+ Q3 y( a$ K
when Ci>1001 and Ci<=2000 then/ ]3 |1 ^% m$ G% P  V- x
       print qi=5;/ k' U$ R5 U$ |% V4 E" ^
when Ci>2000 then/ R: I0 [' O7 D9 K7 e( c& O; {, i& ]) _
       print qi=6
8 r# A/ M' X) i$ |+ E. @5 ?& yend;' J) j& v5 p, y6 w# `8 X# |& N
end;* K) d9 W; \: Y2 N' v
2 n( v) E# L7 m1 ?# P8 o
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?) P2 i* }# J; T: Q0 k0 j
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:" m; K5 B* A4 M$ @9 C
(number : integer)
% [: K% z2 `" |9 h: x4 q# Wis
/ ]& j( b7 @+ N* e0 \do: D4 W1 o- y- v7 ?+ X' A
   inspect number& Q/ q2 O0 b# Q' F
       when 1 then
2 x8 y5 w( ~( J- G5 Q          print "not a prime number"
  ]2 Y8 m4 s9 v( P9 c: j       when 2,5,7,3 then " e- T. x8 i; Z8 c- a& @
          print "prime number"
2 \* J. t8 ^' K! m. s$ q       when 9,4 then ( G" D' ]; |4 g& `
          print "square number"
( a8 s' l9 r) O       else
0 R2 e" H, m3 }) `4 {          print "no special number";2 q- s0 S# G* W" M6 @
          print "or number greater than 9";
* v0 V3 e) N# |! Q8 w   end;6 c, b% Z0 _8 |+ ]' ]
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-9-21 17:21 , Processed in 0.014187 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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