设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7556|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
$ X  Q" ?+ _8 l       Ci :integer; qi : integer" {( `5 T! N' s  r" l3 M
do - o+ \+ G1 J/ D0 q" f* ?! P: h
       inspect Ci% Z" i2 G6 C% m% @. h) y# A
when Ci>0 and Ci <=150 then 2 M. l$ J' g" \/ l8 e& P
       print qi=1;9 w; }' Y$ w: s- X; [& ~- E
when Ci>151 and Ci<=500 then
, e- o! Z; z- `       print qi=2;% M8 H6 j8 s% B" {
when Ci>501 and Ci<=700 then
1 ]# p) u8 m3 y3 c4 D& l. c       print qi=3;2 D9 T! t) V. Y: C  y$ s- w! V
when Ci>701 and Ci<=1000 then
. \- B: G9 t! @" O% ]       print qi=4;
  y1 u  y, X7 W: ^+ gwhen Ci>1001 and Ci<=2000 then$ @  j' F* e- T8 U
       print qi=5;$ h8 k. e1 G* S* J: j$ h+ P
when Ci>2000 then
  k- ]* J3 [6 s0 ?: j+ }       print qi=6) L& l6 y) B7 K2 |% u5 B
end;, A( o3 E- k$ t# P, ], a* o
end;
: ]1 P! p' Z) n; u# c$ m0 t
3 P  |  |1 Z! ?* Z          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
9 h& H: r" m$ F! A( z6 _          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
4 ~' B+ g! M4 E(number : integer)/ [  K9 A7 ]- Q
is
& F1 q* }" Q9 M& r- V3 d9 n9 xdo
* P7 _# g9 |' Y1 L4 `* s   inspect number7 A& ~4 `0 r6 F& w4 f
       when 1 then 6 i9 t! V9 a% P
          print "not a prime number"8 V) ^/ L: P' W" A, u$ d# t/ Y; j
       when 2,5,7,3 then 0 |6 e9 Y, {! W' @- F
          print "prime number"  ]9 q, J. m/ r# C3 L9 Q& r1 p
       when 9,4 then : C: {3 q4 E% U" G4 Q; s. P+ A% i
          print "square number"9 X6 V( }5 c6 m6 Z3 {  G
       else
: N( L& ~2 t3 G) _          print "no special number";
  U1 @5 A* a9 V# A, T2 e: ?( b- V! q          print "or number greater than 9";
" I$ C, A. n' Z- ?+ Q, m; t" A5 h6 z   end;- e. \  j0 ?5 W$ G2 A* F. z
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, 2025-12-14 06:28 , Processed in 0.021144 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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