设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7445|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
+ a" n, _: `" o- \+ z       Ci :integer; qi : integer
4 ^2 }/ ~: _! {. Hdo
0 d6 V$ z. ~- y2 `2 p1 t4 F; \       inspect Ci  _0 A4 N7 \, v2 Q: Y
when Ci>0 and Ci <=150 then
! K6 v: ]0 }) v  Q       print qi=1;# z, z- e# h2 m+ l, R
when Ci>151 and Ci<=500 then
9 `0 E. S8 H6 ]0 |       print qi=2;+ _/ h5 I! g/ A1 E  Q$ l* {
when Ci>501 and Ci<=700 then* G, t. z' k! k2 g! O' z( T6 Y
       print qi=3;# n& |- K$ a0 C0 x
when Ci>701 and Ci<=1000 then# M9 ^% E6 m2 i7 @% V' n; x
       print qi=4;, U& p! t( H$ X; `! l
when Ci>1001 and Ci<=2000 then
( f# u  G! n4 s1 o1 ^2 B       print qi=5;4 c! e' X4 j+ U& `5 a9 \9 K
when Ci>2000 then2 F+ M6 A' s' t" i
       print qi=6
* L0 ~5 w; v$ s2 Aend;9 Z& C0 y$ p, B* c
end;+ W3 ~7 `+ ?; q* M/ [$ t* Q
; R4 l/ m9 y+ n" F9 E
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
, S. m% i3 ^  F- ]) i          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
9 C8 {& {5 |+ {6 I8 G(number : integer)0 e  T  J, o# v0 |
is/ t' d% p2 ^) O
do4 u- C! E7 P- J% g- k) R' M+ W
   inspect number
- \5 e. V% n& E2 q: @& `8 Y1 m' @2 f       when 1 then
2 Y8 c9 Z* W! w- a          print "not a prime number"2 \2 m: j9 i8 h- f* G' n
       when 2,5,7,3 then
: B+ p2 g$ D# `" T" S* U          print "prime number"
* _4 k( R6 P8 `% ?/ Y+ z1 X( p/ [       when 9,4 then
8 H( h( B  m- i1 _          print "square number"
! Q5 T8 d" F2 }9 V$ Y4 X) l/ k* t       else+ f# n4 }8 C+ j1 a. s- D% N
          print "no special number";
( B* M$ Q5 P7 S1 J, \          print "or number greater than 9";
$ M- y! b% P+ @0 B$ Y, a* f3 h   end;# h& j$ U4 W" A& Q- `
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, 2025-11-25 23:26 , Processed in 0.011873 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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