设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7798|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
" W( N! }/ I5 c" m' _  D       Ci :integer; qi : integer
* K' F/ `) q( V3 rdo
! |- }  m, [7 Y6 k7 e: ]       inspect Ci! i. a! B% d  [! u, F  U: M, u# [; U
when Ci>0 and Ci <=150 then 3 e: z! `4 Z' `. l$ p
       print qi=1;
8 V5 ^! h3 D/ V( j3 X1 Twhen Ci>151 and Ci<=500 then+ B& h! o9 |. a- B, F# K, M
       print qi=2;0 C4 n! m$ e" g9 s; ]
when Ci>501 and Ci<=700 then- Z+ m' H% N' C8 X9 p* \+ B6 T
       print qi=3;
- C" u& Y5 V0 h. Xwhen Ci>701 and Ci<=1000 then
" N$ I2 u3 Y1 i0 M: I       print qi=4;" p9 r" _+ x% x0 M6 B
when Ci>1001 and Ci<=2000 then( X* _$ ~# Z' C
       print qi=5;  ~! D* Q, O1 ?3 l) O' W
when Ci>2000 then" I. h" k/ \+ k9 D
       print qi=6
5 m( b: e. L- \& O% R; x& k% V; S6 P4 Hend;
' o, ^  }/ ?" s7 s2 Qend;
9 C; S, W* l; T" Q% h# j$ \  E& @1 T5 M: [
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
1 z: R2 u# d/ z. r9 A; a. ^+ e          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:' E" u/ n2 J. w: d7 ?8 ?
(number : integer)
& h: a/ g7 z1 _1 q4 b1 [is+ [  B2 P) I$ D5 t. F
do& d& y, y5 Y1 o
   inspect number3 {. Q8 T2 o3 Q7 A) Q
       when 1 then
: s  S9 M( O# [) [  ?          print "not a prime number"4 P* H& g. A* d+ A2 \1 z0 }
       when 2,5,7,3 then
) N- c4 ^' F( E1 Q( D/ ~4 V          print "prime number"% b' k2 G+ j8 Z0 }( E* G; u% ?$ j
       when 9,4 then
8 ~# _2 J5 d( D          print "square number"# Z! c, C  Z5 I/ V  b5 R, b
       else
; w$ r- |, h. I2 \  A$ d          print "no special number";" z2 o) j0 y5 c/ X$ w
          print "or number greater than 9";
4 V* V' h5 I& k9 E   end;- j/ y9 x7 a: q# O
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-1-25 15:27 , Processed in 0.019843 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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