设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7503|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
% @! \, Z" k2 L, d) b6 F. o4 L       Ci :integer; qi : integer
1 X" W8 g1 }  \% `; tdo 0 j' X# y# l- E$ j8 Z
       inspect Ci  o# p$ S( ?* z4 |8 b" X4 L7 W
when Ci>0 and Ci <=150 then
) @: V' m  `, O% O* H" z% `5 o       print qi=1;, z) l) e- h5 W6 |' K
when Ci>151 and Ci<=500 then
& v, E9 _! R2 E2 ^       print qi=2;
5 ^! ]2 |7 Q% `( B4 t1 Y# B$ Pwhen Ci>501 and Ci<=700 then
& g: o' F3 M5 {  h; |1 j: H       print qi=3;: k0 C; ]) b* j+ V
when Ci>701 and Ci<=1000 then; ~7 A2 P  U/ v1 u- B
       print qi=4;5 ^" G6 {# w: H
when Ci>1001 and Ci<=2000 then
! ]" X7 t/ V8 t$ Q       print qi=5;
% U/ Y, a/ U1 p( o7 @& w7 p+ l: }. P$ C5 B( {when Ci>2000 then* x6 j1 J& X8 w6 O- W# w
       print qi=6  D% a& A4 O/ ?5 n
end;
' o3 }5 m) }! @* Wend;
& c7 Z: s( ~: V1 u% E7 l
; w% I+ J0 o/ Z6 \          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?3 b- z( K" j  H! d; R* B% A& G% x/ B
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:! a7 t  l2 L1 G# u  b
(number : integer)8 X6 z. R, b0 M8 S
is; Q3 C( d5 L! {1 P6 H; I' ~
do( S* O2 Q2 a4 j) A$ v
   inspect number; c6 j5 D4 l: w" d- {) J
       when 1 then 9 r8 M$ @) |' L' O9 p
          print "not a prime number". R- J: {2 @' M  d; n
       when 2,5,7,3 then
6 r  I( j) L0 T          print "prime number"
2 Z. G3 X9 a) f; I! P1 ^% A" ~       when 9,4 then
4 h, {! Z: K' z( Q0 w          print "square number"' |2 L2 o# W- r/ E# s3 V4 O" w4 G$ \
       else
- y- k: y7 Y" y7 i6 M$ u+ W          print "no special number";
4 I  R: K3 m) D* [: Z          print "or number greater than 9";
/ t" n- h, Z9 U9 U   end;
" i4 a  b% {# J2 i! ~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-12-6 13:33 , Processed in 0.023439 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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