设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8687|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
/ l# ?3 o' V- p5 S5 |       Ci :integer; qi : integer( {: @& ]# C$ y' |
do
( M) X/ c$ u# b+ c# q       inspect Ci5 G& j  }. d" V6 A8 {& K* M
when Ci>0 and Ci <=150 then
! I6 i/ w! g! B  t& d0 m' B       print qi=1;( X  z5 L5 I+ z, L( m0 c; `( e( i
when Ci>151 and Ci<=500 then
3 g( T8 w" n$ \+ ]       print qi=2;
5 b4 i% J4 v! |/ Z" K$ Jwhen Ci>501 and Ci<=700 then6 Z0 [/ ?; l0 ~% c2 _6 x
       print qi=3;) o1 ?9 o: i  C& F/ D
when Ci>701 and Ci<=1000 then
% }% l; g' e, |. C5 R2 F! a; A       print qi=4;2 h4 W1 k* c+ ~2 ^  I
when Ci>1001 and Ci<=2000 then+ a9 Q# k4 H9 g, r
       print qi=5;* h. N  A  N# \: [; ~0 k/ `
when Ci>2000 then
/ L2 ~0 V  m6 L6 _. q/ N( T       print qi=6/ G4 J3 ~) C& m( q$ }  @
end;
8 P0 e$ H5 F$ I; Hend;6 [  k9 Q9 F9 G* ], r
/ I2 |% p7 s, ?
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?* `& K5 V. K% E# U6 p+ W
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:: q8 o! B8 i: c& d& V7 k' Y$ x
(number : integer)
$ P( T# v/ z; z. c% Z8 i  His
& V( U/ b, O1 V7 l6 l! }3 rdo9 e4 A% B% d9 K+ S8 _' k
   inspect number( R8 c1 I8 }) S7 v$ t& v
       when 1 then ( g9 d' O. E2 G# D+ x& Z5 P) g
          print "not a prime number"" y) M$ ?# h3 l6 ]
       when 2,5,7,3 then
, L) p! l$ B; A& B8 b1 `          print "prime number"# X8 a& e% `' T* @) h7 l
       when 9,4 then 2 X- V: G' H# \2 e( k3 H& C/ u4 a
          print "square number"
5 w) u2 H7 A. V3 }+ J) d  `" H       else" ?5 H0 T$ m1 y/ D9 G' V
          print "no special number";
, x! o" D9 x* W          print "or number greater than 9";
4 A2 h7 E; b$ O- k. y& G5 C. \$ B   end;8 T3 y) c; z8 D: D- a& L& j
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-6-7 17:34 , Processed in 0.014491 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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