设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9251|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
) ~2 K% ^, g- B+ o6 S# v       Ci :integer; qi : integer
, U( t1 L/ @, T5 [9 [do 6 J. |+ F+ U6 I! e5 R( E
       inspect Ci0 v3 _) L  }9 L+ j( U
when Ci>0 and Ci <=150 then + }* p3 K) m$ D. w& E- R
       print qi=1;) _* w1 n0 i/ ~6 p  m+ v
when Ci>151 and Ci<=500 then
* p" r$ w7 p8 k. g5 {. O  K; x       print qi=2;
1 V8 G* _3 ]3 Y6 Fwhen Ci>501 and Ci<=700 then
: P" L* R2 x& X3 x1 z       print qi=3;
6 b/ ~' R+ n) I/ w, d4 d  Zwhen Ci>701 and Ci<=1000 then
* Q& r4 M( r* K& O2 g# ^       print qi=4;1 \" ^9 @9 x- Z# F5 B/ a( T% X
when Ci>1001 and Ci<=2000 then
4 o2 y0 d1 N& x3 u! M       print qi=5;
7 {3 j% k& T* ~) {. {! O# T3 Dwhen Ci>2000 then
' P% s" _) ?* I( F- R$ R5 V       print qi=6( v" Z! F9 L( Y! ^; t% B) q3 j! W$ u
end;
' ]% N, c& o  Hend;
+ L4 k% o5 [5 A" M4 G, H. |; U0 h. G3 ^! J: T
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
% Q' H& Y$ k5 g$ C! w          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:" u. ~: z* B+ `
(number : integer)$ w& K0 e8 s1 A. B7 ]" p: W
is
' J0 `6 _$ ?5 odo- Y6 [) {- d2 M
   inspect number* X, a. c% b6 \% y- i- p2 E0 F
       when 1 then
8 P3 c! n* G( {+ h          print "not a prime number"
  Z* P1 _. ]8 D) ^6 L       when 2,5,7,3 then
: W+ K' M3 W' x1 a          print "prime number"1 h! {- Y$ F' x6 g: J
       when 9,4 then
) e# I) r) M0 Y  Q. F6 Y          print "square number"
' P! b6 U9 k' m' Q7 ^! p       else/ }7 A- e. F$ B0 J1 F. |
          print "no special number";4 y( a: i. q; {) H* i2 J  ^
          print "or number greater than 9";, P5 N0 z( }, A2 ?' G/ x
   end;2 I3 r% Y! E9 K7 d/ C8 y
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-8-19 05:07 , Processed in 0.014574 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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