设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8767|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is* w- b- y! R7 z3 @. @) n
       Ci :integer; qi : integer
) I! E. N; H2 vdo
+ g; \8 @7 D" y% u, U: n       inspect Ci$ D+ D% B8 ~: C. z
when Ci>0 and Ci <=150 then
8 p8 D( Q' t# }& d0 v) Y5 i       print qi=1;  b& b" n3 m9 G7 o( ~
when Ci>151 and Ci<=500 then" N! C$ @4 m4 t( R  [
       print qi=2;" p" K1 b* Q, i( c1 ~6 ]
when Ci>501 and Ci<=700 then9 U- k4 R: _1 [
       print qi=3;
, c4 e& b1 R, C( L1 X8 w" l& }when Ci>701 and Ci<=1000 then$ d- e, Z4 |9 W5 j* Q4 P4 e
       print qi=4;0 z0 S, g3 D. |/ ~8 ~2 z
when Ci>1001 and Ci<=2000 then
' s4 H% p4 s6 J4 j* Y% z' t       print qi=5;
- Y! ?& m- k+ |$ G" ywhen Ci>2000 then
; O, V6 \( V4 h1 I/ R$ \       print qi=6
* d- a  V3 X+ |0 `1 e# l& Hend;/ {! P; w$ H2 `! ]4 _$ e
end;
6 Y* ~0 f- k4 _
& S! n  b3 G3 l" c9 u0 H          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?* C/ F3 O- J4 G) I  D
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
/ P+ t% o; o/ \! m5 k9 k(number : integer)3 M- n9 f: Q8 l1 D; w
is
( A! u. u$ h+ Wdo  X/ k% I/ V( I# t
   inspect number
1 h$ e# u0 T" M       when 1 then
- c3 J, B% ~, j5 G9 E2 |$ S& \) _+ c          print "not a prime number", X& |7 B* @$ S& h
       when 2,5,7,3 then
6 O& j' @* `9 o5 L          print "prime number"4 o/ ?/ [% G( H* j9 z5 t8 ^
       when 9,4 then 6 }$ R4 x( x, j8 Q( a
          print "square number"2 f* L7 K0 X3 }. o1 Q
       else
7 `1 \, Y; t( u. N" s          print "no special number";# r6 L" z, d6 x3 y! ^7 E
          print "or number greater than 9";( [/ k( G' d; j% A0 d) |
   end;6 c7 `: @, S/ i/ F/ _/ B
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-25 08:47 , Processed in 0.014157 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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