设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8971|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
* I5 ]$ q2 Q/ S+ ]; w1 |  O9 L- H       Ci :integer; qi : integer& u% T5 Y: @  U
do
. H1 I7 q. ?* U2 x       inspect Ci) |; {' P# j- `0 L: l. S
when Ci>0 and Ci <=150 then . n" \2 @  {' ]2 @
       print qi=1;
  ^' b8 z9 Y8 T6 l, j* ywhen Ci>151 and Ci<=500 then
7 J; C4 [1 T/ G       print qi=2;
: X3 `$ n: K  \- u2 owhen Ci>501 and Ci<=700 then
* e5 _2 t/ M9 `: O5 U( {+ G4 x       print qi=3;
3 q& P$ Q0 i, F- V% ?; Bwhen Ci>701 and Ci<=1000 then* x; }! H- M2 A/ ~
       print qi=4;
; h) r! m; @  Q& }, k* j" x! Uwhen Ci>1001 and Ci<=2000 then) l) i6 G8 g+ X! X
       print qi=5;
. S) e' x8 Z* P; p5 @3 ?when Ci>2000 then
  `' d# n* \6 Z+ P1 S: {% P: O       print qi=64 A6 A1 u2 m) u0 O1 \; G
end;
4 L/ W) N8 B7 b- r) E2 hend;
8 y" }6 A) }/ {1 E' \2 X: w( x! H2 z0 k
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
, p" u* o' C9 p$ k, `          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:/ u" @$ E" I5 K% R( I5 M, l/ ~
(number : integer)
- J9 w) y5 [" Q& m* [0 his. [1 y1 D0 Y2 l0 S7 t9 V+ P
do
- {) z! M# w* \   inspect number: l5 `$ Y7 h8 }9 V0 W
       when 1 then ; Z8 r: {! [5 M) u; Z2 o
          print "not a prime number"
' C5 O( ]9 Z: V' |  z  a" @  f       when 2,5,7,3 then
' C1 s# ^$ f* |  c          print "prime number"
) \% ]8 {7 b* X' ^0 q  ^+ z       when 9,4 then
9 z% y) ^& e6 G! I2 S% Y1 S7 T' `          print "square number"" [4 _+ O( u: \
       else
6 [" V9 a5 T/ h+ j" {          print "no special number";6 l: q8 L& Z$ \
          print "or number greater than 9";
! V7 C& I) X. y2 G   end;
, d7 q- U1 r0 N1 P! S! x% T6 Bend;
 楼主| 发表于 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-19 23:19 , Processed in 0.014207 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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