设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7484|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
6 C: F  q% B. @5 _1 S1 z. s" C" ~, G       Ci :integer; qi : integer# C" r# ~  u# H8 G- I5 g
do / X; z! K7 z" {6 q4 u8 y) }9 S% t  |
       inspect Ci
9 k( d5 o. N7 `when Ci>0 and Ci <=150 then $ M7 V- S' d2 x0 y1 h  l
       print qi=1;
7 U% l: U0 N; C6 g' m3 N* m. ?$ zwhen Ci>151 and Ci<=500 then
  t/ c6 p& p, j/ L5 K       print qi=2;
6 I1 i+ H4 f0 `7 G% Gwhen Ci>501 and Ci<=700 then5 c: P" z0 D& ^& C$ [
       print qi=3;
- Q2 M$ h3 D" ^* \! lwhen Ci>701 and Ci<=1000 then* z; k$ \. f" x6 O/ Z
       print qi=4;" o  @, j) G2 C5 n8 i' b: ^
when Ci>1001 and Ci<=2000 then
1 I" e( o, |$ l3 ^       print qi=5;( W; H* |3 x! N, L9 ~
when Ci>2000 then
, ?* z1 Y( s$ j: e4 K7 o: i) K" ^" u       print qi=6
8 g5 L% f6 C" @- ?! rend;( c3 i0 A+ [* V' {4 H
end;+ D( @* c( @. z3 c. |5 w& ^% n
9 E2 R% ]# q9 S
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
9 Q) [: [% i, i9 E2 @" I          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
+ c* R- a/ c) K) i: s(number : integer)
. m2 \+ ]7 u9 T! _is! M; z! W3 D% ?/ U5 y! ~+ u* R
do2 M) m$ j# Z3 }2 }: r3 w1 |7 M
   inspect number- u9 Y& y0 Z& V6 p& n
       when 1 then
& `( i0 o% W3 w. O7 W          print "not a prime number"0 V( D; p6 y% O& w, b0 j0 K0 f
       when 2,5,7,3 then   ?4 B  a& {. Z4 S9 a5 z  g7 q
          print "prime number"; e5 K. ~9 Z' P) O
       when 9,4 then 0 T( x% z8 @, {4 g" n9 G1 v
          print "square number"
+ S# [8 p( X8 x. @' L  I       else
' z4 n! Y! l7 j& W8 X          print "no special number";8 l6 @& X  Z  r9 T
          print "or number greater than 9";: d/ U- ^; K! y& i3 I% F+ S
   end;
+ f8 B. U' L' ^! P1 ^  I5 b# g- Cend;
 楼主| 发表于 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, 2025-12-3 12:57 , Processed in 0.014378 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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