设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6251|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
+ B: X  p% ^% w$ t       Ci :integer; qi : integer: m5 {4 N/ Q. N. w! m
do
4 z& o) k( v( J2 V       inspect Ci& y- C+ h4 Y- c0 t: @  b' N3 `' h
when Ci>0 and Ci <=150 then
" h- u4 v: K- j2 y       print qi=1;" t. `4 n$ n5 D( V( i$ ?, K, T3 R
when Ci>151 and Ci<=500 then" A4 X9 t7 Q, ^  C, F
       print qi=2;7 E& S( h( u6 ~4 Z
when Ci>501 and Ci<=700 then7 K& r& f4 P" e: l
       print qi=3;
. V" m5 s/ \2 s* V* |& Kwhen Ci>701 and Ci<=1000 then
" ]+ K4 p, D) d7 C1 G. f; Y       print qi=4;6 `2 n5 }0 T6 r: E' R: C8 u: S
when Ci>1001 and Ci<=2000 then
7 l1 i: A* W6 B2 V& d4 ^1 b       print qi=5;- g% \8 ^9 d  _, @
when Ci>2000 then
: i+ s1 v9 @: {4 j1 X       print qi=6
' \+ j+ ^+ z  F1 ^% w; ?end;$ r5 `+ r9 V& @# Z8 x
end;; G( y3 c" [$ ~# }* X9 a/ w# d
/ A# z( {" C, e9 U+ d+ ^1 W- d7 n
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
( M* Q+ K1 Q8 V6 E2 _/ }          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
9 n2 q* B5 O/ g(number : integer)
: k. [3 P: k# s( R6 f! N3 Q1 F  Pis0 P7 h  \) w8 {; E3 C( V. T; V
do
  }, `4 F6 M. j" l: q+ l   inspect number: H0 a5 |. g0 T
       when 1 then / _! ]2 R  E7 o6 b7 Z* z9 E. w
          print "not a prime number"9 e  }- }) ~6 h1 z9 N; S6 T
       when 2,5,7,3 then
" q3 m8 E& T3 Q5 `6 c8 z/ B7 i          print "prime number"8 z( i0 ?! r! w9 A& t3 \
       when 9,4 then 6 z' @; ?8 F6 k, K
          print "square number"% A( j) y$ y0 J: m" C
       else
3 k; N3 f, K3 A6 [6 }9 ^          print "no special number";2 d% `; r6 o# ~3 x
          print "or number greater than 9";& n! j+ S* T8 X/ k
   end;
% D/ y6 f5 M# ^2 L3 ]3 h4 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, 2025-5-12 21:50 , Processed in 0.018571 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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