设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8129|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
4 r4 V# G5 h) `9 u& M       Ci :integer; qi : integer
; |3 ?/ n& J5 U7 hdo ( c3 \; ~! Q) |1 P, M) h
       inspect Ci
# G: _% j! m* U* |/ t8 c* \when Ci>0 and Ci <=150 then
- f( m: }! C+ F3 U       print qi=1;8 d9 o$ u. m/ x* K  Q  X' x, i" i. w
when Ci>151 and Ci<=500 then3 Q; n4 ]! r. P' T8 z# u; E4 {2 g1 u
       print qi=2;
) U' K; Y8 J; uwhen Ci>501 and Ci<=700 then7 H7 D6 l9 h0 J- [6 h$ D
       print qi=3;
" c. j( V+ J& w5 I" [' W5 Ewhen Ci>701 and Ci<=1000 then
, [5 ~$ S+ W9 h       print qi=4;% V8 O) ~& i: l' m1 j9 ]
when Ci>1001 and Ci<=2000 then
+ R5 c" Q' v0 C       print qi=5;
( C; N* Z. g' `& twhen Ci>2000 then! }% e, P! T, [, K
       print qi=6
& {3 _% [; h4 p8 _4 Iend;- z8 s$ [3 X6 z0 w
end;* J- \! f& n* T! O7 h
+ W) C& g6 R8 g! X9 E9 l
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?- c: W: z; H$ {. g9 `& G1 f
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:! ?; S& t. X. l
(number : integer)+ y# f  z3 T2 M1 g- V' L" N% q. v
is( W+ N3 ]. e7 v& e$ r" z
do
+ b3 W' b. R) ?7 E, ^   inspect number7 b, p! }2 l) T0 M/ j" P- F
       when 1 then
7 a& w( o3 h: b) ~          print "not a prime number"
! [( k' G0 O( m4 h# o       when 2,5,7,3 then
5 e8 m* |9 S: ]: v; K5 C          print "prime number"
2 Y. x: C  V7 P       when 9,4 then
) S- j, }) y9 |; g& G( v          print "square number"
+ [9 j7 M! |) k  N9 y& ~9 o0 N       else
7 p1 {% ], b& Y          print "no special number";% O) |  \! o9 p- p9 p
          print "or number greater than 9";
% l# U. S9 a4 e# Z, W9 E) m9 r   end;
' ]# A+ p, X' j3 aend;
 楼主| 发表于 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-3-25 03:23 , Processed in 0.018186 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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