设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8691|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is( I: Q; ]* ?& _$ \+ V$ E% a& p
       Ci :integer; qi : integer8 X& \8 K; k  F
do 0 K9 i" e* Z( p. ?) Q
       inspect Ci, G" y7 X) h; n5 r
when Ci>0 and Ci <=150 then 6 @6 h7 F2 Z( J2 B2 _
       print qi=1;
' N- W. x, P3 [& U; m- O, vwhen Ci>151 and Ci<=500 then2 q: `+ H1 z% s
       print qi=2;6 h2 l8 R4 b. s8 e6 n
when Ci>501 and Ci<=700 then/ T& ^" x2 \  V$ e2 d
       print qi=3;
( C) x5 ?7 x0 `# V( d! Ywhen Ci>701 and Ci<=1000 then
8 I3 e& y% k" y8 D- Y       print qi=4;# ]* R8 J( j: |" y% `4 J
when Ci>1001 and Ci<=2000 then' @7 U( b2 o) ?2 G4 f. H
       print qi=5;1 g3 C  _' C% A7 W; |
when Ci>2000 then
; v, v% M" t8 o       print qi=6
5 Y% Q* ~' y0 |0 c, Lend;" T( e; a/ U+ m+ @7 `
end;
- z3 c+ `. o9 }9 Z- x
; p1 E: J6 |! W          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?# O7 c3 S8 G$ }9 a; o- r. r, B. G
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
$ @# B' x. N6 N' B. n) G(number : integer)) g7 g* y, w3 @
is/ |3 I; y( K4 B) U: e( w
do4 t0 z0 p: _: [1 |( ~3 J8 m" F* S7 L
   inspect number
2 r: Y) c' ~5 _" F       when 1 then 3 \, R3 \; ?! Q' N' s; Y) H5 h0 r
          print "not a prime number"
+ c. X) R0 K, |0 Z       when 2,5,7,3 then $ |+ t( w/ `) Z/ ~3 Y- M' P
          print "prime number"
; \9 u, B4 E8 u% s( G       when 9,4 then
: V2 V) l$ v$ q          print "square number"
# B. O8 o7 F- r4 J       else
0 X6 [6 Q1 w- g5 h, D) W0 ^4 Z          print "no special number";
4 E5 I( Q5 J0 b6 N( q          print "or number greater than 9";) P, C5 q6 L2 Z8 F+ S2 B; {0 ]  l
   end;6 ~" v$ B% s1 Y3 d
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-6-8 18:31 , Processed in 0.012505 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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