设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8492|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
$ Y. X3 l" d2 L$ c) ]$ z  I       Ci :integer; qi : integer
3 T# ]0 t9 o9 S( ]  ?do * K4 ~6 ?8 P, l# f0 q/ e8 g
       inspect Ci
1 c3 v" z2 |+ H3 uwhen Ci>0 and Ci <=150 then
& K) x. q: S- }0 v       print qi=1;& A, o. x. C3 H: C3 F
when Ci>151 and Ci<=500 then
; [& W7 |& K# `: A       print qi=2;
: l' ]" h- J- `when Ci>501 and Ci<=700 then: D' L( [% e7 A/ d- A7 O1 g. J
       print qi=3;) n9 \/ X# J2 g4 ~# G3 H6 k
when Ci>701 and Ci<=1000 then
( v" \4 }; L  o2 W2 w9 o       print qi=4;9 v" e3 t7 o2 G: Q+ ]) q6 e6 x5 ?5 I. A
when Ci>1001 and Ci<=2000 then  l0 f2 T, b/ w! {' `' ^/ G
       print qi=5;. d) o( r/ [: n# j
when Ci>2000 then
4 W# n5 w2 }, T4 x; ^' d9 \       print qi=6: G4 ]$ `" y1 w$ C) a4 w
end;
8 ]! X: v+ Y0 ^end;
& @6 e4 T0 C9 R4 M; W% R2 ?+ }, i- g/ r) o  X+ ?7 [
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?" p4 t' Q; q! C" A1 Y& q5 Z+ ?
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
7 x! [  u: Y' Q* R( Y5 |(number : integer)
' ~8 W! T- k* o. m6 J7 c, ]8 cis
4 b$ i) g5 Q+ f' m  r  rdo7 X/ K$ I$ N! Q
   inspect number: f" O& k3 |  _% x, M( W
       when 1 then
0 V6 W% }5 k8 d* C6 i$ f          print "not a prime number") @; G$ I# M* }! f9 |
       when 2,5,7,3 then ( v9 b7 m5 j0 P- p& _9 u* {* F
          print "prime number"
& |& L! D6 o& y6 K4 R8 H# Y! k0 @       when 9,4 then ; T0 ^% ~8 [4 N6 u7 `) H) w
          print "square number"4 @+ }! y! z3 ?* ^% T
       else
/ u! ~8 s" q7 u* B, K7 M3 V& J          print "no special number";* y" A, X7 s3 @1 V3 u+ n6 L3 l
          print "or number greater than 9";
" P6 b  s, p$ C6 ^   end;
/ J7 d8 g& b7 b: h+ P& p: ^9 ]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-5-2 08:42 , Processed in 0.014072 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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