设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7438|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
+ e4 ~+ p  K3 m- O8 B7 k6 v       Ci :integer; qi : integer4 c: Z* N& L8 q) Q: A
do
: O( j+ {0 Y2 k- y5 n       inspect Ci) V& g, B, k( O) V
when Ci>0 and Ci <=150 then ) w3 }/ ]4 U6 i" U; x4 V
       print qi=1;. [  n' b7 F9 k  @3 V4 ]
when Ci>151 and Ci<=500 then5 w6 ?. F3 I' z
       print qi=2;# c* k2 Z# \- t* i7 a
when Ci>501 and Ci<=700 then
! X8 q4 L3 U# P# r$ \) C7 e# o* j- R       print qi=3;/ T% g9 S9 m/ v: n: x, Y
when Ci>701 and Ci<=1000 then5 G1 V5 B6 u: z, F( T
       print qi=4;
( n- D- Q: A# w4 g( @, W. C, owhen Ci>1001 and Ci<=2000 then  Y9 E& H* A+ B+ q& ~
       print qi=5;
9 L- }2 Q8 k' m- B/ C6 g& uwhen Ci>2000 then
% y7 \' S4 ?6 ]$ j* c- Z       print qi=61 y9 E& j/ [3 }- t9 M
end;
7 ^/ f. k1 T# A. J6 o1 ?end;3 f* f; C3 w) i& u

* k+ W8 g9 l+ x          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
5 y- d" Z& M2 |: [) @/ I" R          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
, Q. L4 X) [# W& a& p(number : integer)0 Q: d" F1 F6 @, a0 J
is- l4 \: t3 h$ q! W6 m2 A4 Y" c
do# ]; G/ b" c# A+ I/ l
   inspect number$ p$ M" Z% _) @: R! o" m; y
       when 1 then
; G+ }  y" o3 Q+ v) J, Q, S          print "not a prime number"
5 N6 E  h, Z7 Z3 N       when 2,5,7,3 then , D4 R5 O+ X; k
          print "prime number"& W. \* H  c3 D$ t3 u& [/ V! |
       when 9,4 then
' E8 z" I# n; N/ @' z+ ^1 n          print "square number"; n! x* t5 o1 }7 |/ Q6 R
       else3 d" I' }  {$ A6 S
          print "no special number";5 F3 B" a, u. b+ N& k- W3 S7 H
          print "or number greater than 9";
! \8 e! }) `: L6 Y7 G5 k   end;0 v( w8 j( R8 C1 p
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-11-24 13:28 , Processed in 0.020677 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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