设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7855|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
/ T3 K$ c: ?+ A% `2 Q- M+ f       Ci :integer; qi : integer
0 N  d  i" n$ [/ g) ado
* b( P/ M4 X- f+ f8 k6 S       inspect Ci
9 E; s2 e7 a: N) wwhen Ci>0 and Ci <=150 then / w( @) D) \9 d: n  k
       print qi=1;
7 M- b+ Q) _! X" [; A& k3 H, Rwhen Ci>151 and Ci<=500 then  l# w+ L% Y* B( u) @# V
       print qi=2;
3 u  I! Y1 c8 F; c. M: f4 swhen Ci>501 and Ci<=700 then; w% c- M* s( Z1 d' ^/ X& U
       print qi=3;8 u1 ?& X& X! `. r! y1 o8 N4 R  M
when Ci>701 and Ci<=1000 then7 X& l; x! C5 X  h3 F
       print qi=4;
  a2 \% T  f. m" n* Kwhen Ci>1001 and Ci<=2000 then$ ], q0 z* t4 E7 D7 x
       print qi=5;* x& E" z6 i* |+ }; m& Y
when Ci>2000 then
- P8 O6 Q  O6 f* x- _& L& I8 j       print qi=6
+ s" r/ ^. ]# Y' j1 bend;
/ ^& J& |' c) s! h; i( R8 m6 W: U) h. vend;% ?' O1 ^) P$ {8 `2 q* U

0 _4 G+ ~; W) ^+ A1 ?3 Q          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
) v8 R# r9 h, R8 A9 i# Q          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:" c4 V4 V- m# f% O) o( @
(number : integer)
4 \9 c, p4 W2 }0 k& E3 _is: t& l7 O6 N& ^5 a$ g8 `0 g6 w
do
$ i2 l& e7 G1 ~: [' _# R7 u   inspect number- p9 R+ R% k" R6 t: P6 U" }
       when 1 then
5 n( u  B2 P1 I3 D2 _1 m: S1 D. n          print "not a prime number"
1 h+ }& E7 f" R$ W       when 2,5,7,3 then ( c3 ?3 g8 s7 Z+ L  d
          print "prime number"! i2 B$ v6 ?1 g. L7 F' B
       when 9,4 then
4 h" Q" D2 r" a, ?$ }+ K          print "square number"
; v9 k5 z8 O0 Y$ q       else
* S+ s$ p4 D; S  T3 ~          print "no special number";% r: h3 h- {) \
          print "or number greater than 9";  Z* p: A7 k3 K  K6 Y
   end;
; L! ~# L3 T$ c  Rend;
 楼主| 发表于 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-2-4 22:25 , Processed in 0.017053 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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