设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9396|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is) Z- ?  i6 S" D( D* ~; q0 I
       Ci :integer; qi : integer
) G" Y) J* f: S$ a8 v" C" L9 Kdo + a- K) j7 c! k- [
       inspect Ci
. z7 }) q" s2 O: i( x0 l; t0 R& [when Ci>0 and Ci <=150 then 2 Y. I6 i6 q$ i& K( Z7 A- }; \' D
       print qi=1;
. T5 Y1 y: S1 F- owhen Ci>151 and Ci<=500 then
, ?; Y% `+ S! z7 k0 l       print qi=2;
& R2 S& m9 i5 k& @when Ci>501 and Ci<=700 then
1 X, U9 T& y) ^# t       print qi=3;9 K1 ~. B; x" m6 Z
when Ci>701 and Ci<=1000 then1 \5 A, ?5 Z- j1 j7 j" k$ H0 b' ^
       print qi=4;9 K- B# M; K3 g2 ~. i
when Ci>1001 and Ci<=2000 then
) t4 J& }/ Y% I) s       print qi=5;1 ]9 ]% H6 G! ?/ w/ {
when Ci>2000 then
+ J  E; K0 C) J, m       print qi=6
4 j/ @$ X: c% o) lend;6 \2 A# s# w' f5 |8 q3 |) Y
end;
1 R+ }8 q5 m, w$ w5 J
, d2 ?6 _+ z; s9 J- B          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?) X6 n3 }4 [2 k4 M
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:  ^& U% e. w6 W! w
(number : integer)8 e: f' ~0 L% K1 @$ X7 Q3 d
is
+ S: H' W( E! l9 a! C6 ldo
* m7 K" [" t! ?5 z' H/ i- [   inspect number
  S  \! d# o9 E! x- Q& E3 u       when 1 then
% E( @# W: g$ r+ C% y          print "not a prime number"
" q$ ]3 t% g2 b) I* p       when 2,5,7,3 then
7 @, m8 w$ B$ S: f          print "prime number"
4 z% J) Q4 T2 {4 c' l       when 9,4 then 4 ~+ P" b2 {0 O& Q+ |2 e$ o
          print "square number"
! z% }$ e" J/ _. o" U; s3 |       else
: C' w- g' W8 _8 h, }7 |5 e( V, m: C          print "no special number";
6 u8 S5 a$ n* c8 y/ V# r          print "or number greater than 9";
& b) c+ b  G' H: V% k4 G   end;/ F9 @/ X+ _2 v$ P1 R
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-9-12 18:47 , Processed in 0.013994 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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