设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8654|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is1 K7 t; ?* T$ w8 t8 }
       Ci :integer; qi : integer4 h( K' i5 C& g/ X+ q6 p: Y
do
$ m+ B6 k* [; w+ a7 |       inspect Ci7 T. I' I. f. {
when Ci>0 and Ci <=150 then
1 Z$ K! Z$ J% e) r       print qi=1;
# D& \4 [3 C, q; Q+ o) owhen Ci>151 and Ci<=500 then0 e$ u/ o) G" ~5 a( n1 \* R
       print qi=2;
/ O" K7 F, H0 a5 Owhen Ci>501 and Ci<=700 then
/ f( z1 [) F3 }% w5 {2 e8 M$ M- S       print qi=3;
* Q0 q7 y7 u1 cwhen Ci>701 and Ci<=1000 then
. w6 `! d0 Y3 ]1 {       print qi=4;& `) ?7 D) `& C; {
when Ci>1001 and Ci<=2000 then( O  T5 g% v' q: q4 U! Q( {, w
       print qi=5;: r: r3 F6 q2 f; }1 V0 t
when Ci>2000 then
2 L; }) x  M1 Q/ t9 B       print qi=6
5 V" x7 p4 Z% zend;6 v7 w7 m$ B9 C8 z& N3 o% t
end;% f* r6 ~' T2 Q# J* i+ U- i: v

  R) u8 B+ }2 n2 W          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
4 V/ O+ }) O# \7 h$ O5 O          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:2 d" @* A3 {1 S" T4 i7 h0 n
(number : integer)8 e' c4 ?8 ^3 Z( q7 u. I
is
2 B* D9 @* B, Q( E$ ddo1 W8 I& p  z) X8 |0 D
   inspect number
' W' }) @9 v5 [* j: B       when 1 then
$ [7 Y7 r7 U6 s& d- s          print "not a prime number"
. v: C6 t5 Z0 Z/ |: ?; b% v       when 2,5,7,3 then , J8 H, F+ }2 Z' m. G; |+ ^' U
          print "prime number"
3 L$ s: O6 k1 p$ q4 F* h       when 9,4 then ! w9 V$ z  E' B: |: r9 _, P
          print "square number"( C$ C; r% f( x% r: W
       else; S7 ]! I: M+ x% |# \6 R! B
          print "no special number";
3 x( `( Y6 ?9 t+ y9 r( o' Y5 I5 H          print "or number greater than 9";) M6 T" F; w% B) x& K
   end;- p+ G# n. l# c
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, 2026-5-31 14:10 , Processed in 0.014490 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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