设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9009|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is% j7 q( G/ W& {; X) ^  T5 |" Z
       Ci :integer; qi : integer7 l2 A! j2 m; Q4 A/ e5 ^
do - v" ]( d9 x4 D* c) b1 p9 r& h
       inspect Ci! b7 z8 Z8 o) c, u
when Ci>0 and Ci <=150 then 2 Q; q% |$ }: P2 \
       print qi=1;5 u3 T2 J& ]8 W: a
when Ci>151 and Ci<=500 then+ {8 m/ ~2 y$ H2 T* ^0 q
       print qi=2;
4 o9 `; y% W- r" H6 {+ pwhen Ci>501 and Ci<=700 then
. o- W7 G" ^7 ~3 y       print qi=3;
4 P, z. [# |, X: L3 Rwhen Ci>701 and Ci<=1000 then
6 L! |# ^3 Y+ K$ L+ C- M- r" T$ X       print qi=4;6 |. t1 B8 I& v! N) T3 V
when Ci>1001 and Ci<=2000 then6 \  W0 N5 H% t, h& q  n  R
       print qi=5;
2 O) V/ M, R& t; S6 ewhen Ci>2000 then
6 |: }  X8 k1 a# }       print qi=6
. }, N' ~  h2 M* j* o: |# W) b! iend;7 |5 m* `, f$ F0 x+ x. ~0 v
end;9 a/ w5 S% c' H% g! Z0 P
7 B6 Z' D) Q" O
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?& X3 R* M6 ^& e$ m/ T; j
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
0 a4 I9 D) k% ~! \) i(number : integer)
1 c" S9 }5 [* w# z: Eis
  @9 y& {1 D. h! \8 a. S# L" r$ s# Q. xdo
8 P$ B7 _7 K3 P. p" F1 W   inspect number
- P+ {( R7 {* M1 x2 S       when 1 then - Y  }% A9 B2 H- h! D
          print "not a prime number"3 H5 v' p" e9 t" D, C
       when 2,5,7,3 then ! ?! B/ O! {6 O
          print "prime number"
6 J/ L) L& P3 i) v' g' Z3 f       when 9,4 then ( D8 k( S5 l8 r- \$ d3 N8 F
          print "square number"; c& |; I( _8 c4 g9 q1 W8 D
       else
2 z+ t3 j: `: j8 p          print "no special number";4 R" v, u( \8 g7 O
          print "or number greater than 9";! m5 f( k4 f; c# m$ l. H1 L
   end;5 Q% X( w: G8 r) V4 c
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-7-21 13:33 , Processed in 0.013339 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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