设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8586|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is3 k/ C: L- G: ~
       Ci :integer; qi : integer0 y0 @) @# k, L: o. b6 l% p
do - P+ p, W7 E! I$ _
       inspect Ci, v- F8 `6 D" S) h# z& Y2 n; N  ^
when Ci>0 and Ci <=150 then / c& M0 I/ H3 W$ _4 ]/ I
       print qi=1;" X/ c$ Y2 H, x" h  k9 j; ?3 @7 J
when Ci>151 and Ci<=500 then. b- G+ s+ R) v' b
       print qi=2;- ^' U+ L; A8 R9 D
when Ci>501 and Ci<=700 then6 |; @& X! V  }
       print qi=3;
) W/ _+ l6 a8 N# \8 awhen Ci>701 and Ci<=1000 then6 a! M% _6 K5 E' G- E% A. o
       print qi=4;
5 |4 l5 p/ K  |# S0 _when Ci>1001 and Ci<=2000 then
/ y( S% b) D2 d( Y$ R' O       print qi=5;
, q& A5 C& @8 k- u8 k' Ewhen Ci>2000 then! q9 q. H+ L! I2 Q
       print qi=6
% [& C9 J0 D  u1 w  Q& [7 Hend;
# t$ [2 H( p9 cend;& {7 R* e4 ]0 _8 J
) m7 {0 Z- `& Y2 C* p5 V; {% ]
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?. X* R' d, G  e: _9 X/ ?
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:- h. X* c: }" b. x
(number : integer)# e( B5 Z* U  ]9 }8 o7 I* K
is& c2 Y: y6 [0 z! V
do8 e2 P! o* s: e1 V
   inspect number) [) {+ U% s, l6 J
       when 1 then
5 L  o7 u- Y% x8 o, h          print "not a prime number"
  A+ @% }. F( |- R8 j4 ^0 Q       when 2,5,7,3 then ) R- |* a" y# [5 R' O! \
          print "prime number"
6 V4 m) q9 N6 h/ [" F. ]       when 9,4 then   F" X  \) g% x# P2 d  e4 F
          print "square number"
  }! Y. @& V) q# m+ ?+ _5 ]* |       else9 l- i8 r% q. P0 E: q, \+ j
          print "no special number";) d9 A% i  D3 D
          print "or number greater than 9";
, E) I, y1 k# n4 o1 G1 r   end;. s. G0 o6 K& W" c' F9 h
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-5-15 07:57 , Processed in 0.019771 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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