设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8274|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is9 _* ~4 [& v* ^# Y. z9 b5 ?! x
       Ci :integer; qi : integer
/ a9 D( R2 F9 edo
# v( Y/ x0 A, N9 t6 ^4 F       inspect Ci
. J9 E" O8 _9 Iwhen Ci>0 and Ci <=150 then
' B& O9 s  {8 Y+ W+ O7 \# ^       print qi=1;, s% f$ D: Z$ P9 ?9 @. k6 b* [
when Ci>151 and Ci<=500 then
/ k/ u, Q  W3 J6 X9 N* V7 Q/ v       print qi=2;4 P" F$ H6 T5 Y8 I4 y
when Ci>501 and Ci<=700 then- z+ H# n+ s+ F  a* K' t- d2 W
       print qi=3;
! z6 X# _! R( Nwhen Ci>701 and Ci<=1000 then  `1 f5 O0 s$ s
       print qi=4;" K1 d9 L5 \% h$ B
when Ci>1001 and Ci<=2000 then
+ J: G0 ?' R$ i7 t       print qi=5;+ U5 j) y, N! c+ m, f
when Ci>2000 then8 [# R% k& B0 r' C
       print qi=6- h2 {4 e0 h! X
end;
9 q5 m4 B8 d* ]) c/ uend;
: }( T: m: L9 A
# b( A3 |* b" a# a          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?; {2 I# h( Z: C5 p' m  ]! Z
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
. l& g% p/ @- F  N& J(number : integer)
1 c2 n# M3 V+ |- g9 j$ Kis
- y% C/ N* d% B" S% Sdo5 v$ a' e$ D: C  H* i
   inspect number
( u: [  N/ |1 Q% [% @       when 1 then + {! z0 j8 A' \  S% e
          print "not a prime number"! R4 u; Q' y* @3 J
       when 2,5,7,3 then
" q/ R  O' D2 Y" x; q1 o3 \. w, }! @          print "prime number"1 h! O1 l8 O% K8 b  m9 G6 A9 f
       when 9,4 then
0 d5 E$ B8 J: N0 f8 ^& p% u& M; |1 S          print "square number"
7 k4 G4 X( E# S1 f1 h4 T       else
9 p0 s! u+ \. W) |0 ~4 p          print "no special number";3 Y. G3 h) o' j4 |- q; ^
          print "or number greater than 9";5 W* V' C3 k  K9 ^
   end;
) s  r8 }. O8 |* P5 hend;
 楼主| 发表于 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-4-12 06:59 , Processed in 0.014454 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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