设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8355|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
1 d) B' t4 O' w& r7 V9 v& ^       Ci :integer; qi : integer3 F" s8 g6 a2 C( r6 ~! `+ C! _
do
1 n# O3 J/ M- q( a: G0 k       inspect Ci/ z" e* T0 R$ `2 G
when Ci>0 and Ci <=150 then : w$ G9 c" H" T2 x
       print qi=1;
0 Z; `6 d' [& P) d  X0 ]: Q, iwhen Ci>151 and Ci<=500 then
9 g3 s, D8 j, p( j  r       print qi=2;- `7 ~, ?8 a  a0 u& r' |
when Ci>501 and Ci<=700 then
. D6 [8 i9 q# H       print qi=3;. @3 n& ^6 i) k1 L4 D1 L
when Ci>701 and Ci<=1000 then  K9 ]  y  `- S( X$ G6 k
       print qi=4;
0 C, [9 A8 C/ ?/ O9 B* J  F' h: \when Ci>1001 and Ci<=2000 then! t  N; f6 ]8 T& Y4 L" u
       print qi=5;
# i( X/ _! x% K' L9 W" l; w* awhen Ci>2000 then
. k! c0 M) l+ ^# K6 R       print qi=6* P- `8 j  O$ [) f/ @
end;
& q! d' K' z# ~: X$ nend;: c# F) M+ C, W  u' n& [8 {. x, g6 B

2 T2 \2 r  ]: t9 K  ~          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?* |7 ^) O- k2 \
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
, d; u5 O; `( z( m4 U(number : integer)
; @4 Y" i( ]# ?9 o; J, Sis
7 }  m/ _3 F& E& ido
$ T! P1 |7 E) t! W! S   inspect number
) p6 V$ Q' k4 R6 M4 ]+ ]" L       when 1 then
! z$ f2 T9 @. g+ v7 h+ Q          print "not a prime number"
& w, D$ ~: g9 U% Z/ M       when 2,5,7,3 then ( }" K" d' B1 T  c1 {
          print "prime number"
7 m$ z# d. Z; }$ h! J( J( P- c       when 9,4 then
. Z: Q% N2 N, k          print "square number"
8 T0 u9 X7 A( n0 t8 L( ~9 m       else; k$ N7 ?0 T- F: a
          print "no special number";. c  F" h& E. Q3 e) A/ ?
          print "or number greater than 9";  ?4 T3 H- {/ w) s7 O: a0 ]
   end;% o0 i  _3 i* u3 c7 {  o. d+ m
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-20 13:23 , Processed in 0.017871 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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