设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8192|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is1 |/ k2 f! Z5 [6 O$ d/ I
       Ci :integer; qi : integer! W; S" f& U; }
do
# v  V+ c  `* c       inspect Ci
! |4 n* I( ]- j, x# wwhen Ci>0 and Ci <=150 then
2 ?" G- H; J4 J/ ?/ Q/ W( a5 M! }       print qi=1;
9 e) v7 A+ J  g9 B9 f$ lwhen Ci>151 and Ci<=500 then' k$ h+ G- d8 P) l/ o9 x
       print qi=2;6 n  h( \3 T, |1 p# I  E
when Ci>501 and Ci<=700 then
) a3 k3 t" u( y5 L+ C4 u) T6 T       print qi=3;
/ M3 \7 n+ ^$ y8 X) Awhen Ci>701 and Ci<=1000 then1 ]7 N- c5 c: i; h* }  y. M
       print qi=4;1 f3 m8 X% p/ ?2 t, B1 r3 c
when Ci>1001 and Ci<=2000 then
3 W) H3 e% z3 E, n2 ]       print qi=5;. J; `! a4 y8 t5 z/ G
when Ci>2000 then, J! Z( t  k' X; L+ q
       print qi=6
+ w/ Z3 ?  o& @end;
; |0 f/ A; U' h4 hend;8 p) J& a( X6 r) |0 {  U
" K( u- Q4 a9 T; D' U
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
* v2 n& R4 R4 s6 y5 Z          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:& U3 t& a0 {, N. t
(number : integer)4 p- L3 d  r  t: o
is# g0 x6 }1 ?" ~
do
# @6 H8 _/ Q- x- `   inspect number
, v/ c. |0 ?+ \7 h# Q+ k       when 1 then
+ b! G% e2 R" h          print "not a prime number"
' a7 D$ z& r' J       when 2,5,7,3 then 1 e5 y6 g5 b1 c: Z8 b2 b
          print "prime number"; v! ^- r# Q" X% P/ w7 J% k
       when 9,4 then
# U. l2 L+ X3 G          print "square number"
, A; G* i8 W& K9 E) [/ J       else
; _/ U  s7 h% w, e( J. V9 X          print "no special number";$ [1 G/ h2 l# p& ~, j; v# P( ]% P
          print "or number greater than 9";6 R/ L, [0 A' ?
   end;
+ j2 F9 K- j; v3 m: `: r) wend;
 楼主| 发表于 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-3-31 22:10 , Processed in 0.013929 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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