设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8715|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is$ I. j. {& ?6 t5 A$ r. y7 a
       Ci :integer; qi : integer! M9 m  [. b- |8 k
do
% J$ h/ J7 {3 A- Z' W4 z       inspect Ci
4 E, e# o- m' C1 A; Xwhen Ci>0 and Ci <=150 then / J" c  p- v$ b( S, v) G4 A  S
       print qi=1;
9 V; O8 O- k$ H) `( {when Ci>151 and Ci<=500 then
. F; s# k9 w% S; H       print qi=2;
4 J* {9 T. k. {when Ci>501 and Ci<=700 then, a% s- U. h' ^; ]4 }
       print qi=3;2 [9 ?+ {, L" ~7 T
when Ci>701 and Ci<=1000 then, H$ X( S. P6 s. x
       print qi=4;
5 o4 s3 L3 ~! K" nwhen Ci>1001 and Ci<=2000 then
6 P' e- ~& v; t4 P  {2 l       print qi=5;
; u1 R1 ~, U& @. m. s4 H1 o2 ?% Y  Ewhen Ci>2000 then8 w2 a' |5 P* v! t
       print qi=6
0 }" U: Z  E" f0 g! y; ]' m$ Y2 mend;# ^8 I3 Z: D7 ]# `3 x  E
end;
0 v, s/ ~4 l9 b& Y
! a7 h6 `# M9 j) i- f          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?- f* o+ @! U$ o7 x# |5 u4 m% n
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
  f2 V( \# y; ~(number : integer)9 Q, b, M0 _% }$ \0 w
is$ M; s9 [$ }( e0 I
do
+ b$ R  }, N5 @# M; M   inspect number( b. f/ H9 k# a+ t! k4 n
       when 1 then
6 q- R# f$ j* u, x' o* \          print "not a prime number"
% q: i/ N2 z( G7 F& g/ J. {. q       when 2,5,7,3 then
( e- k3 t, w8 q* }$ g; X5 f          print "prime number"
4 m% s/ m/ M4 N; b: f       when 9,4 then 7 x8 m- B: _: k: F/ R& {8 ]  h% H/ G
          print "square number"1 b+ j% t! B/ S/ G. h. w3 X6 o
       else  u& b. p6 ]! p5 M! ]& O' _( N
          print "no special number";1 w3 @- y8 M* A1 g# T
          print "or number greater than 9";
' Z1 j. A3 l/ P& a, I0 j   end;
5 y$ a6 N2 T5 {2 l; M0 j4 `9 vend;
 楼主| 发表于 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-6-14 23:35 , Processed in 0.011131 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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