设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6249|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
1 I2 m; S8 Y( b5 U5 ^( E8 u9 Y       Ci :integer; qi : integer  c7 D/ m2 c% G/ G( z- ^
do
/ i( t; V" x4 D) M4 c       inspect Ci
9 K  U' X5 I. i! ]when Ci>0 and Ci <=150 then ; x+ \2 Y* K$ \4 j
       print qi=1;3 W' ]( E' z2 s* u) z
when Ci>151 and Ci<=500 then% f' X5 V! D4 O0 q
       print qi=2;) x. c  s( r' D8 k9 n# A
when Ci>501 and Ci<=700 then
2 L' F0 Z1 }$ v3 @       print qi=3;
+ q! @% w( m9 p2 O- Y. @. g% L% @when Ci>701 and Ci<=1000 then
& z# y5 e2 C3 k/ F6 G0 j. }       print qi=4;5 ?# d+ M0 I$ Q2 @* Y" n
when Ci>1001 and Ci<=2000 then. h' M1 c' s0 F, v; h2 i9 [
       print qi=5;
. g' t  }1 c) }. i% j0 iwhen Ci>2000 then
# y% W' m; B9 h8 B0 \# K; ?1 o       print qi=67 C& P$ s, S4 n1 _" R
end;9 f3 y  z) e2 M# D" \' N! D6 g# U
end;
/ H& f) z. Z+ h1 f) B5 M
' A& {. H" L9 C* O, J& c* _          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
. x6 c# a8 h1 d          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
, V' e2 |/ L$ e; z9 C3 N1 E(number : integer)  c5 \8 ^6 \0 S5 s' p0 ?" [
is6 I/ C/ g: O; l
do
3 L  N+ K# Y& \6 w# L   inspect number
# M7 B" ?& o% B2 W4 j2 N       when 1 then " i4 I- A- h5 a2 I7 x+ A+ ]6 |$ t
          print "not a prime number") r5 T7 A! t, |
       when 2,5,7,3 then : ?' l3 T* B9 B0 z. {8 }* Q. W) p
          print "prime number"
3 c3 b$ m* [5 k       when 9,4 then
# W5 C5 b( m$ V! c          print "square number"
) w1 A% h: }' z7 d5 _# p5 C       else5 ]- o5 E. ^' ]4 r; t3 P0 O
          print "no special number";  x- a/ Z, Q* c
          print "or number greater than 9";
# z$ v3 }' U8 W; f3 z3 q0 p' J   end;( Z3 o: W$ X4 n# E/ M
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, 2025-5-12 18:46 , Processed in 0.015257 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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