设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6263|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
) D6 f/ H- d- w* _0 [! o       Ci :integer; qi : integer+ X0 d2 s3 N9 \
do * }/ t) T7 L* y/ h  Q: c) a
       inspect Ci. `, a+ g( U( ]8 F( l  m
when Ci>0 and Ci <=150 then
( S4 |2 ^; V6 I( C       print qi=1;5 k+ |; B0 T. ]' L9 V
when Ci>151 and Ci<=500 then  ~" k9 X8 V: A  z" x% S/ i
       print qi=2;
/ h6 V5 i0 L  e4 Twhen Ci>501 and Ci<=700 then" N; N0 X1 R  T/ b% I) y4 V
       print qi=3;
* ~* y/ g8 O1 @8 Dwhen Ci>701 and Ci<=1000 then
# V2 Z  O3 n% g7 |/ S% D. U6 d       print qi=4;" A8 {* O" a& A3 Z
when Ci>1001 and Ci<=2000 then6 V  f/ p" o$ O. F3 N- s4 ~: X. ~
       print qi=5;. |% W" c3 o7 B& ]) N3 v& `! x
when Ci>2000 then5 ]) I5 w/ ], T) N
       print qi=6
. o2 @7 d4 ^9 o7 Z( U8 Fend;
2 N$ x2 h& Z6 @, N: a1 K5 q! yend;
4 d+ g- Q% y# _' z2 q$ y+ p8 @  d$ [4 s
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
( [) Y0 f$ o2 V5 s2 l          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
5 o7 I' x" t* N1 N(number : integer)
4 Y- U0 L2 V$ O3 ~' V2 w8 Dis5 i/ J) q% W1 H+ D( k
do4 ?* b7 Z1 s$ N2 u& O. |
   inspect number  y, V9 e# d1 B+ W# ~
       when 1 then
( U6 Q) _+ I9 j. N/ h4 Z          print "not a prime number"
* f+ h: T; g3 e! D" U0 S8 V* w       when 2,5,7,3 then & f0 `" q  k. i
          print "prime number"3 O$ W# g0 Y! g  I
       when 9,4 then
  n1 _+ ]- T/ f/ ^& h  p" h5 b6 _% I          print "square number"
: z+ E) ~& \- M7 x2 ?0 o4 k8 v. d       else' `: P" B. D  n6 j& |
          print "no special number";
2 [" Q! C  ]" X4 k          print "or number greater than 9";- ^1 A" V2 ?- Q9 Z- O% I
   end;
. c) u+ _, G& M) O) H, Q% Nend;
 楼主| 发表于 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-5-15 07:53 , Processed in 0.017121 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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