设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6473|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is' B7 r7 D+ |1 V2 e$ ^8 H" m) H9 u- i
       Ci :integer; qi : integer
; b' [' {5 a8 P8 F5 S( E6 Zdo / v  Y* u+ P6 O1 ~  |- _+ A
       inspect Ci
$ |+ W+ G+ U) |+ ~7 ~  ?when Ci>0 and Ci <=150 then 8 v' L5 A- Q; [- R8 d
       print qi=1;- A, K* _7 x% [
when Ci>151 and Ci<=500 then& T0 }5 v/ q+ a. w' c
       print qi=2;$ @4 L& F7 T) v4 Y7 u, W+ t$ w
when Ci>501 and Ci<=700 then" W) g) o7 P  K! K# J( s
       print qi=3;1 g2 [( ~" l! \! N
when Ci>701 and Ci<=1000 then+ c3 g$ u& l5 t- P7 k
       print qi=4;
2 Y3 @; m0 a$ o) h8 J- _& ]when Ci>1001 and Ci<=2000 then/ M/ V2 N! D( [! ?" x
       print qi=5;2 m2 Z, o/ P, y7 P
when Ci>2000 then5 C  W0 y/ q; \" z9 ]( k
       print qi=6) a# C/ k; P/ C' n* u+ Y
end;
1 \- ]3 O  r2 [2 mend;
, O8 _0 H! X1 @! P) c' q
0 I) q' v5 T- S5 Q! U4 E          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
- U8 @: J/ W9 Q! G          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:/ \) H9 o8 d* {3 x+ z* P
(number : integer)
- {4 ?! B6 [( V4 O2 jis0 H' d3 E& @* ~, a/ @: `
do- E0 }% W0 p+ M7 s" O4 p
   inspect number
, Y* d5 W" z2 G$ b$ Z       when 1 then ' C  W; P; N( c9 f
          print "not a prime number"
9 R$ m: Z' U) V1 N2 `       when 2,5,7,3 then 3 O: Z3 a% N7 b0 n/ ]
          print "prime number"3 F8 T+ \: U6 F' @
       when 9,4 then 5 d0 G. X  g, n" S; K
          print "square number"! M- }% c+ I0 {8 \
       else
' X% h; c/ I2 [- s  c# o/ [3 J          print "no special number";
+ x5 ^- g2 ], ~1 E2 X' `          print "or number greater than 9";1 M3 T6 T/ p) x! R' T+ G# n
   end;
7 y% p2 J. b+ W' q. z3 Jend;
 楼主| 发表于 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-7-2 07:50 , Processed in 0.018611 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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