设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7285|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
( \5 ~: H% g# ~6 L2 [       Ci :integer; qi : integer; W9 [: a5 E3 v, l# ]! @
do   G$ N7 b: ^: k# z0 ]" X" |! J4 s
       inspect Ci$ K( I* A! i& P7 n1 P) g6 w
when Ci>0 and Ci <=150 then
7 g/ @" ~! e8 `4 [- @       print qi=1;
. s2 }$ |8 B$ N, Ewhen Ci>151 and Ci<=500 then
* ]  w1 @( I; m. U4 I/ q" ~' r       print qi=2;
/ r' I$ l. S4 Y+ [7 [5 Twhen Ci>501 and Ci<=700 then
% @# Q0 M% J- L3 g2 V% n       print qi=3;8 f' |7 {9 r' O$ Z1 ^' F
when Ci>701 and Ci<=1000 then
2 Y8 v8 A. ]0 q8 p+ ~7 `  _       print qi=4;' w4 W/ x2 A# {2 o% L$ p* |4 z
when Ci>1001 and Ci<=2000 then
  M! a# A5 \/ I! |8 b       print qi=5;
& I6 a' Y8 K; c3 E$ v2 c' ~' zwhen Ci>2000 then
+ ^8 F+ ^- p; \       print qi=6
2 K- t, {; w: h- R$ D' z! cend;: u0 O8 I2 E1 i" T
end;) Z: T' D5 X" d

9 ?; r. N; v- |( x) Y2 t          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
5 X- D4 N8 s; D  U; Z          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
% z: g: H% U1 z5 y: ?, P. T- f  l% [6 a8 U0 y(number : integer)
+ G% X) Z( {, ~is7 s4 `/ f) [* y( N0 @, R
do9 @( u, R6 w7 X) q) n- N# [( U0 a4 _
   inspect number! U; v1 a0 V' i/ x. c5 W+ B  S
       when 1 then
5 B6 ?  ~0 w* }: _2 t          print "not a prime number"
! _  D' I  d% M0 {" H5 b" V% W       when 2,5,7,3 then , N0 r6 v3 D$ N. D/ {2 o# u
          print "prime number"
' f( z0 ^2 n+ C% U. P       when 9,4 then
" `( C# |* _2 z% g# ?          print "square number"
7 x/ N8 W3 V3 M2 q- y       else' m! m$ @& r/ X" \/ M
          print "no special number";
4 }8 H) w) r3 I' Y/ l% U# S          print "or number greater than 9";
9 p, a- _1 T$ q7 w6 y! ?   end;; u) K  m' j# c8 r( I& a
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-5 09:45 , Processed in 0.013820 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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