设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8623|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is; l" t6 ?! p6 N* p& W5 L# q
       Ci :integer; qi : integer
( ?7 ]7 Z; j* u  A# r( Q' cdo & s6 K" {# g# A0 d0 j
       inspect Ci
5 l$ [# A1 w6 f7 y# L4 R4 H# awhen Ci>0 and Ci <=150 then
" i  i* |( M; L% D4 [# T       print qi=1;, V1 |* c9 s: c2 ^( z3 b# g7 L
when Ci>151 and Ci<=500 then
5 `7 J$ h% |- m! [5 M8 L+ x       print qi=2;0 o  a$ K9 c$ U7 q
when Ci>501 and Ci<=700 then2 @% Q0 t6 o6 q: I0 g" `
       print qi=3;
/ C$ n+ [8 ~7 Jwhen Ci>701 and Ci<=1000 then
: w  c1 j/ q" I) R1 W8 j) P6 e2 d       print qi=4;& v" A( B8 t$ Z5 \! r; l
when Ci>1001 and Ci<=2000 then2 W0 N$ b# Y" l; K+ f+ Y4 V8 K
       print qi=5;8 k5 U6 }% b0 N0 I; i
when Ci>2000 then
" c5 l# ^8 e# z7 E, h; O       print qi=6
! _! I7 y3 E6 dend;
& h4 L0 u* H2 I7 F$ y) ?& S& mend;
2 H' }, h/ a! D7 ?
. [6 k( z% J4 U5 w          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
1 R. o' X5 |* s* B( P6 e6 M          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:6 P. x  v9 l* c% q# B- E
(number : integer). z# X  D/ Q0 J. l: a2 n: l
is
. A& M/ u! g* i2 M7 D, Vdo9 b1 L% w( Y0 n" q+ c" t
   inspect number+ V. y. i# e: X4 o
       when 1 then # p4 H/ C$ v, J, X! ^' ~8 _
          print "not a prime number"* L) H* w& K/ W! I
       when 2,5,7,3 then # J0 J( O6 t8 R3 U1 f
          print "prime number"
5 j# S8 v2 a, v' \# F# l       when 9,4 then ; a- N! C2 z0 f, ~% @1 i
          print "square number"
* E4 {: R4 `+ |6 N       else6 B0 a- N6 x- ?
          print "no special number";4 {" G8 V& |  o: j& E- k! W
          print "or number greater than 9";" C: N  y0 D# p0 [% ^
   end;: K- H/ s1 j5 w. @, F
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-23 14:27 , Processed in 0.023686 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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