设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8680|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
9 m) {6 y" F, z& A  |       Ci :integer; qi : integer0 Z( O; ~% [* d7 d9 X  w, P
do
. p6 G( V+ k% h/ a       inspect Ci+ j. {" Q% F8 t9 S, V
when Ci>0 and Ci <=150 then 1 k  A4 f, _, S+ l" W
       print qi=1;
7 r9 O) F3 G; w% C: @6 Q3 Qwhen Ci>151 and Ci<=500 then
0 M0 |) i2 `+ g       print qi=2;' {1 G4 C4 |$ |0 e$ H4 h7 ~+ q2 L
when Ci>501 and Ci<=700 then6 X% J: x; q( ~) l* w+ m- H
       print qi=3;7 K4 Q/ z; O. l- r( n
when Ci>701 and Ci<=1000 then
4 J$ e  D2 }: P4 Z       print qi=4;
$ J" b- O1 ^! X! m- nwhen Ci>1001 and Ci<=2000 then
' n5 Y& B' S; r  J- b       print qi=5;
7 g" d: V% @9 N3 |when Ci>2000 then2 R  F* J5 F! Q
       print qi=6" V* ^" c5 G7 m
end;
. E5 F. y3 }1 m; v* Hend;
# j& E- e2 J& @3 Q8 w# Q! c8 u7 T/ d8 a  P3 d" Z) T! t& O
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?* h2 g/ @( ?6 r+ ?  p0 ]2 E5 G
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:( e/ [6 R* M9 _" P  k) f
(number : integer)+ _9 X3 M' a, K; f6 U. [! e+ K2 F
is
8 x; f/ |& K) p  w! s9 z2 [" ado& M: `+ {; }" h# S- b# ?; ]/ y+ `6 C' j
   inspect number
/ Y# g9 |$ ^/ F# D" V5 d+ z0 V       when 1 then
3 \  u' G# e* _: J: T          print "not a prime number"
" C, i: y3 H+ d) n, j5 G       when 2,5,7,3 then
/ Z* ]( k) W8 T3 V/ R% H. s          print "prime number") H  A4 H) M' O) ?) Z
       when 9,4 then % m# C# E5 J8 k7 \/ d( K
          print "square number"0 T: T) \5 H9 d" }- ]2 d* N
       else
: k9 W; V2 P( W  l, T; a# b# B8 P          print "no special number";
  z# x$ ^( m' W) Q0 b: E' c          print "or number greater than 9";8 a# l, B8 k8 d4 S
   end;
7 s. P& ~' i2 y! Send;
 楼主| 发表于 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-6-5 00:51 , Processed in 0.013561 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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