设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9478|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is3 [0 y" f+ j" y- S
       Ci :integer; qi : integer
! c3 A0 G5 x+ ^9 k! Z8 fdo
3 _9 y: l. I- P7 o: l3 \       inspect Ci
( [2 B. P' U, S' p3 y; p: {! Fwhen Ci>0 and Ci <=150 then + |) K" @; J$ R" u. @
       print qi=1;
. L' h% N: m, F$ i4 \3 K: bwhen Ci>151 and Ci<=500 then
3 ]1 F  C8 c# i2 n/ j$ ?       print qi=2;
; u8 V" L7 ?( n" I7 |- o+ J, wwhen Ci>501 and Ci<=700 then
* d( d" z% ~: h! W# b. N" M" @       print qi=3;
$ X1 W) D5 y7 W0 }5 v8 Owhen Ci>701 and Ci<=1000 then8 f3 }  U5 u% O" ^/ K: V
       print qi=4;! X8 q5 I0 r5 N) {$ p" g5 X
when Ci>1001 and Ci<=2000 then! L, G$ `' O* g6 K
       print qi=5;
3 B* D; h2 S, T& Xwhen Ci>2000 then* H. B' A8 j- o7 O4 K& W( i2 E
       print qi=6# G0 e7 s" d/ V8 I7 E
end;3 B5 b  C- G; n. S9 U
end;
* T$ @' j$ Q. ~3 I5 n2 [% Y7 g; p1 F0 Q+ ?* N1 h) i
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?6 f7 ?& n: H4 n  u- L: O' o
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
1 L7 g/ k; V% [- s(number : integer)5 D* c0 l9 C0 N7 I3 p% w
is
" a7 m3 g( v. b4 L; B$ k- Z0 tdo% w3 V- p: V' w. q. _% Y0 U
   inspect number
0 Q  g% s  Q- b1 X) L       when 1 then
9 f7 M* |; x* v, R          print "not a prime number"; l, M+ d/ h% l0 x: T. _9 q
       when 2,5,7,3 then
+ j* L$ \6 Z  ~  |5 r( M& i4 V          print "prime number"
( O* D8 U8 h' \% W% W       when 9,4 then & e$ u* _! X% G$ g) d' T3 y
          print "square number"
$ M8 v8 n" c5 m) l4 e7 h4 q       else
" t! Z& ?, Q+ G# w; x% {          print "no special number";( Z/ w3 A# z6 m: @
          print "or number greater than 9";: |; J& h: q* `  a& c
   end;
6 [& I. r9 e# {5 G% Send;
 楼主| 发表于 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-9-21 17:21 , Processed in 0.018988 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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