设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8233|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is0 R+ `: x* f" k: K
       Ci :integer; qi : integer
+ Y% c# F  k& I; {do
! q( i9 g3 N+ K$ G7 K' h       inspect Ci/ G$ I/ o9 C( v$ s5 Y
when Ci>0 and Ci <=150 then
- e' k+ m+ A+ ]6 f: _/ R6 M       print qi=1;; X5 U; ?7 |% t- N! o
when Ci>151 and Ci<=500 then
- L, M0 s2 ^- g4 Y: G) ^" C: p       print qi=2;1 ]8 _% \9 g0 K, R! b( V5 i
when Ci>501 and Ci<=700 then( u  w8 e0 Q8 J, K  f
       print qi=3;
8 ?/ h9 H  y4 L% {8 v; _2 ~6 o: ~  M' xwhen Ci>701 and Ci<=1000 then% s$ ?: S) u# [* d
       print qi=4;
6 T1 h7 P% F  d6 H" \6 owhen Ci>1001 and Ci<=2000 then
+ N( N1 D+ R  E  l  Z. z% R8 x" {       print qi=5;
, z2 b2 e& ~  bwhen Ci>2000 then1 T# [$ Q$ e: }0 \1 d
       print qi=6
6 [- s7 @4 N! W4 @* [0 Vend;2 B- G0 u: p: b; ~. E4 _
end;
2 g7 b. z- l( |% ~9 D, A
2 n$ G+ [2 V. u. J- S8 L          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
9 K( ^5 t) x' b# {1 p          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
+ Y& t8 o7 e$ g(number : integer)
3 [* d7 y+ N0 |is& j% k, m+ B4 i7 H: X6 h- u1 }9 L5 g
do
3 \2 k  |6 ?$ j0 n! u   inspect number
1 u. Q, _) _: n/ y7 R       when 1 then
4 v5 F6 K9 E& }9 Y3 K2 i) a          print "not a prime number"
2 W$ \7 o  P' P" q6 I* ^9 A       when 2,5,7,3 then " Y" L; b, k: b
          print "prime number"& o4 H& h8 W" B% H# w6 g8 ~! [  ]
       when 9,4 then : c. l, d* O# b# ?& l
          print "square number"
: K3 V% k) \7 h! y       else! ^- X# r* |/ ^2 m! \" [! _) A2 \
          print "no special number";4 x  f9 |3 \; I; I: M
          print "or number greater than 9";
% M7 T5 F* Y$ W. W- ~# J$ K   end;6 v% y. f" J. u% [
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-4-6 00:48 , Processed in 0.016287 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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