设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9217|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
) _( f, U4 z- b2 K3 \. k       Ci :integer; qi : integer
! X  a5 u( S1 H5 ?6 S4 H. sdo
4 C! @  P/ m# s3 ]4 k; M1 d       inspect Ci
8 ~1 a5 K# h: \8 z4 Uwhen Ci>0 and Ci <=150 then
* A* a' A2 T4 T# X       print qi=1;2 x' B) C! [  h* q! P9 s5 L
when Ci>151 and Ci<=500 then
( _4 G; A7 q$ Z       print qi=2;
, I& Y# g6 U( G1 G" ?when Ci>501 and Ci<=700 then
  s. B$ P5 a9 T6 c) Q       print qi=3;% f+ U- l( L- f( k' y% N; l
when Ci>701 and Ci<=1000 then
6 _! b/ Y% ~8 [# ]# z( b) `       print qi=4;
3 o- I0 a# w. v, k$ _1 `$ d1 g1 Vwhen Ci>1001 and Ci<=2000 then
# R& q3 B! g' ~2 h' p: R' s       print qi=5;
& R' K) e* E% ywhen Ci>2000 then
1 M1 X  C4 ^7 T. S: \       print qi=6
! y, k) P* H6 Eend;1 ~1 J! h, N' M) V+ g# e1 {0 |
end;
' E+ q1 i8 k1 ?7 W) t) y' Z' H: Q
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?- f" D3 I& v# n! z- @( C
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
+ o( V: |5 [& z(number : integer)6 A1 u" Q) l( K, I% a
is& f, G* s2 _! d; D
do
! v( Y( [* t( ?3 j   inspect number! k( g; K! P9 Y/ n( n
       when 1 then 2 E5 w7 _) D: Y/ L& W. }* A/ ?/ D" N
          print "not a prime number"
$ n1 J! \& M! O! w1 v9 u- B       when 2,5,7,3 then
! j5 J1 ~' {. W! N2 h          print "prime number"
3 S, ?, M& U% o* ~# a5 B       when 9,4 then ) z6 J- c/ Q% [4 J
          print "square number"
8 W( l; O9 q, b- `( n( ^% O- I: |       else% \1 q4 c3 f- Z" ^
          print "no special number";3 N+ N2 U! N7 q# s9 B6 F) k
          print "or number greater than 9";
3 ?; a8 a" O  w8 p   end;
5 M  }/ P; \3 \) wend;
 楼主| 发表于 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-8-12 05:12 , Processed in 0.014476 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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