设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8256|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is! E) q+ l2 v5 x' F
       Ci :integer; qi : integer
# L, U! G7 I7 Ado   L3 c$ F9 ^/ `8 h3 I
       inspect Ci
& Z8 O0 [# _; \! e/ v; h* Ywhen Ci>0 and Ci <=150 then $ d! y; g7 U. E+ Z: @0 p1 _" ]
       print qi=1;
$ m& n1 e. S3 `0 @" Mwhen Ci>151 and Ci<=500 then" T# R1 d1 Z+ |- n  _
       print qi=2;1 |8 ^3 r$ r( `, u
when Ci>501 and Ci<=700 then. E" v9 H9 ?' X: U& h* i9 Y1 v4 i# C
       print qi=3;- E/ F7 J9 K/ o) H  y5 E) X
when Ci>701 and Ci<=1000 then
' b$ O8 @! F: S2 t3 c. _8 v/ i       print qi=4;) ?/ r1 E) n5 R. @& |9 e
when Ci>1001 and Ci<=2000 then
  t4 x0 O2 C( q5 p       print qi=5;
9 O0 ^" i% ?( T7 N7 i! G# Cwhen Ci>2000 then
9 _: X9 x/ w1 K0 u3 [3 c+ x       print qi=6, B- x0 b6 c; _+ q% m: {8 T; j9 y$ M
end;) D7 P( ]$ ]6 ^" G* R( `0 Q$ o; _6 M
end;
" \9 G5 a) L" |  I* S9 c1 b* |. P5 a
) e1 u) l& `* V' a          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
% g* m3 Q, n" J, G) t6 h2 P          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:$ \6 Y9 G. P, B1 c) e7 e6 S4 z
(number : integer)/ M0 l. ^8 D' m/ e& t+ j8 d
is
. l0 Y) T' [/ ^, f; mdo
0 i) N6 [! P; ]. r- E- C6 t( S8 U  S   inspect number& X2 q$ V; Z. m- N/ J, T: p
       when 1 then + b# ~! V+ y# C( K0 u( u
          print "not a prime number"9 N5 y0 V) z, g% }" C
       when 2,5,7,3 then
1 C2 u+ ~+ B! X6 [  q# L          print "prime number"
, j$ ?5 B2 n8 n. [7 c- f       when 9,4 then
9 O. s, M" ?! O7 q, ^6 M          print "square number"; S! R- p6 z6 F3 y
       else1 j. P+ m& Y& O' s
          print "no special number";
( c! \3 Y" M7 c2 y& z          print "or number greater than 9";# z, R4 ^6 o+ W: f* |  D
   end;
. y+ N6 n" ?8 x2 c" O; qend;
 楼主| 发表于 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-9 11:20 , Processed in 0.017664 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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