设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9022|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is' }& @: l1 F, z$ Z; y. A! o
       Ci :integer; qi : integer" N* X+ ?, B/ F/ g
do
2 P( O/ H9 L) G- v. E       inspect Ci
1 l5 }/ q7 U  o! i* k5 h6 Iwhen Ci>0 and Ci <=150 then
  O/ C2 v! [  ]( G& {       print qi=1;
4 @: l1 y) x6 Z# Z: X- ~when Ci>151 and Ci<=500 then( d% c$ m( R* Y9 r+ v# h: K
       print qi=2;
5 ~& R, V: [( m3 V1 W- }: k$ x; Jwhen Ci>501 and Ci<=700 then7 {4 d6 ?3 Y8 z% O8 k
       print qi=3;. f+ K' E" P  t1 T9 I  ?- ^
when Ci>701 and Ci<=1000 then) w7 k2 Q. U* J" S0 ], @& f
       print qi=4;
8 `4 {+ A: y7 m; Fwhen Ci>1001 and Ci<=2000 then
" ~1 R6 y" p2 g) q       print qi=5;! m+ k( t0 X5 @; I. y8 Y; j. |+ m
when Ci>2000 then9 j4 [. `7 F+ N
       print qi=6$ J4 ~# ?* k# L2 d) ]6 t
end;
0 T' }' [% K, m% W! q* ?end;& B! g2 r6 K4 Z4 U

  a) D- e, k; I" |6 K9 k: t          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
5 F7 p0 i# R% A' \          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:! l% ~, Z- ~9 \0 t5 O
(number : integer)
0 V0 U2 S! [2 ~& D7 j1 n, R7 Xis& Y+ `# T" I  S1 c3 t% u
do# g8 i4 U) h9 q
   inspect number
' H0 \+ M; S. ]! H! Z" r  h       when 1 then ! q. e5 h; e9 y! f# c1 h* E, B
          print "not a prime number"
/ l& D3 L6 \8 |% S       when 2,5,7,3 then
1 W- ?/ k4 f! w" X4 q0 C1 a3 |          print "prime number"
. }) i' d9 F# e       when 9,4 then
5 M( {7 R% J: x! _: @          print "square number", z% h+ `4 F9 i0 {! Q
       else
* G( b7 L, g9 _6 J* d; z4 [          print "no special number";; V: }4 a5 I# K  ~
          print "or number greater than 9";
- B8 @( J2 W+ v   end;9 f- f) M3 X: ~5 {, [
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-7-22 15:01 , Processed in 0.016044 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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