设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9286|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is% |  w  `2 O5 h& Q; s* S9 O+ t5 i
       Ci :integer; qi : integer8 Z/ \1 d- u( S0 l8 m+ f) {8 H- Y
do * i( O4 F9 u; X% u; n
       inspect Ci
  F8 l0 i! ]- M/ hwhen Ci>0 and Ci <=150 then
& K9 N  J- [5 F3 B. F! J       print qi=1;
3 x- [3 q" g4 O. w" cwhen Ci>151 and Ci<=500 then9 p5 L3 U2 b' B! D, F
       print qi=2;% L4 ?  _( a5 }
when Ci>501 and Ci<=700 then
6 l9 I; z" \3 j3 D  }       print qi=3;0 o# L0 S3 m: o9 O+ t
when Ci>701 and Ci<=1000 then6 O  T! k: g7 M
       print qi=4;  p8 ^; B2 s7 ?+ Y* J
when Ci>1001 and Ci<=2000 then
5 J6 p5 V# d1 }* d* l' l: `$ s0 G' H       print qi=5;) }% W6 P) t; ]7 \
when Ci>2000 then
2 ^  v( O* Y# `3 T       print qi=6
; X. z( b% w  i+ w. _end;  J! \3 C5 }+ m, H7 d
end;7 j( u' e, U9 ~* g3 j

  o- b+ A2 x+ g          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?9 e/ U3 q0 X& ^, ~) y: L% Y
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
3 O4 w! s) B4 u. F& i: x(number : integer)
, R8 }1 \( Q9 `! _% tis* R7 b: G" F0 a6 p8 Y. I
do
! X' l$ E- O: d; N# ~# Z" k' H4 q   inspect number
: Z/ @* r, r: m# ]3 G9 v( ]       when 1 then
" ^4 i4 ]) C) @: ^8 I          print "not a prime number"
7 y9 o; p/ J7 S6 Y' k8 `       when 2,5,7,3 then
" x- C3 Y& F; b          print "prime number"2 a) r) Z$ d0 m1 X  G1 q4 y
       when 9,4 then ' S4 Z: z- Q7 f
          print "square number"0 F9 }: Z- K: |2 ?8 D  S/ r
       else( u# z# A; q7 U3 O) C
          print "no special number";+ A- \' i* T5 g7 G
          print "or number greater than 9";  [0 ?& I/ k. N* G0 f
   end;
& d9 m0 M; m0 `; oend;
 楼主| 发表于 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-8-24 12:42 , Processed in 0.029949 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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