设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6483|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is# Z6 O3 `7 f: r% Z. y+ }
       Ci :integer; qi : integer
4 o% @  l- N  i5 D7 p' b! ]: |+ c* @do ' j) B* q4 H1 X; A
       inspect Ci
$ }  w9 v" a- K' s  w! Awhen Ci>0 and Ci <=150 then
0 j- N5 c& G6 l7 c* M       print qi=1;
) i3 I' H( D: g7 owhen Ci>151 and Ci<=500 then& ~% L) F5 |# ?+ u2 |: W
       print qi=2;$ A+ y) g8 B+ G
when Ci>501 and Ci<=700 then* U6 u0 j$ i2 b2 j' g7 x0 J
       print qi=3;+ p2 B0 N. {4 }) G) e4 q
when Ci>701 and Ci<=1000 then6 A/ N; l5 k3 l; D
       print qi=4;
% j* V1 @3 O5 }' rwhen Ci>1001 and Ci<=2000 then
! I. j+ W4 P5 c# G       print qi=5;
) c9 J& D4 ?0 b' @when Ci>2000 then5 f0 f( y( {# p5 M9 r, }6 E- z
       print qi=6
3 f3 t+ J9 `4 _& S" |/ gend;$ O  w' K) p% F
end;0 x# Z4 [  j/ Q% q, [! e9 V9 t

) w( R2 \. y' y. _6 ~- x/ ^          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?2 r7 q8 m& H/ M
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
/ z  V  j2 O- G& \3 t  F(number : integer)
( @& l* H* s9 |% w3 |& k' {. Zis/ _6 V7 M# ?& d& x9 q
do6 s2 t( b7 d( x- D4 d
   inspect number
$ m) I! l, N  o! p" G$ o       when 1 then
" }5 p7 e# X) t- M1 W          print "not a prime number"
9 I; @' K: s- Y4 N, A       when 2,5,7,3 then
( a9 R/ Z& }* `+ u          print "prime number"# I' C6 f* _2 ?0 F$ Q9 _! q
       when 9,4 then
3 P' |6 K+ c" Z% |          print "square number"
4 ^4 u4 o  D6 x, J9 s       else% g) h. {! j9 W3 f, @
          print "no special number";
- n' [  G* M9 M8 @9 a          print "or number greater than 9";% i2 f, V5 p! I7 b  Z
   end;  H+ B7 s; O9 e# v+ h! c' 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-7-3 00:27 , Processed in 0.015177 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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