设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8802|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
; `( V. q6 K/ L/ L7 W, W( L       Ci :integer; qi : integer; ~8 _7 ]. H4 k! f8 O
do
4 B& D/ @' @: P* p0 M       inspect Ci
7 Z" U/ t" A2 _3 S' a: Nwhen Ci>0 and Ci <=150 then
/ V; U' m  S( M: D; M       print qi=1;& J% Y* S4 }- u# _/ y
when Ci>151 and Ci<=500 then
) y4 s/ D( o! a3 ]/ B       print qi=2;
/ L7 n+ a$ m' @: [when Ci>501 and Ci<=700 then: y, p/ V2 d0 L
       print qi=3;
+ E, C7 {: Z3 l7 cwhen Ci>701 and Ci<=1000 then
/ u/ b5 I" P$ H- Z       print qi=4;" v# K9 C. {8 o* \) s! Z
when Ci>1001 and Ci<=2000 then, P( d2 J+ z. z
       print qi=5;; r& C+ Q; w2 u
when Ci>2000 then7 e% w$ r7 q& Z9 l% Q6 m: b! K5 \
       print qi=6/ @6 c* s2 i7 ]5 i
end;( k/ S% c- U/ N
end;! G+ L# Y! A: W1 X5 C' V
4 w2 z& W9 y8 u2 p3 n
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?! m2 n9 \( v8 w
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:/ [0 c" N! Y, e$ Y) [2 K
(number : integer)! Z$ P9 a9 _& n( H8 {4 H  h" l
is
$ }( m8 d$ D7 _! }7 edo
( \6 p/ g: f* a$ W. @" d   inspect number1 ^, j. q, b% v5 }& R( A
       when 1 then ) s) {, ~- D" P/ d1 ^
          print "not a prime number"% O0 P' Y: P# ~- F# X, O1 U2 p% p, Y
       when 2,5,7,3 then
8 c5 m" I0 G" l' o- A7 W) X- Y          print "prime number"! M( o5 Y: E; D& i
       when 9,4 then / L9 I  s+ G5 t3 C7 B( W
          print "square number"
( J1 o0 z/ M, f( L       else' H7 K4 V) f, m# W( `" R8 v$ Z
          print "no special number";, P9 {2 J# b( d4 [* P5 M3 @
          print "or number greater than 9";
5 I2 F/ `% N, l& W! v* x   end;
: K* \) o$ H- r# N  `" R& E6 s* 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-2 16:34 , Processed in 0.013349 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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