设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9227|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is9 d# O" ]2 A0 U: u9 P- q4 n0 A
       Ci :integer; qi : integer
! ?( l: R7 w, \! sdo
0 M' j9 _, o1 O       inspect Ci
. G, Z7 |2 S* z; u+ j0 H6 Wwhen Ci>0 and Ci <=150 then ( f2 u- P2 q( _8 Q  H+ M. z; \' V
       print qi=1;
. G, j. Q1 ^, t( K3 V: N. g% x( Bwhen Ci>151 and Ci<=500 then; {8 h) u$ \, @! ]! p5 |
       print qi=2;0 V0 U# w- M0 r& c
when Ci>501 and Ci<=700 then$ {2 t" J+ Q3 q2 E: D8 y
       print qi=3;+ G8 G- T+ z# }+ H. {
when Ci>701 and Ci<=1000 then; H# R& }/ q: N; Y% d
       print qi=4;
. |1 N/ M7 ]* ewhen Ci>1001 and Ci<=2000 then0 i$ _! u; i8 N. A
       print qi=5;
# c4 u3 d% ?, ~3 _  gwhen Ci>2000 then
7 ~7 [& O! [  P0 K* Z       print qi=6
* i. |- ]0 _$ @, w8 qend;2 C  Z8 Z5 s6 u" r) E; n3 [3 Z7 m1 P
end;
  B6 n3 k! X' V# ^# [% z, v) k
# H1 k/ Q9 L) {9 S/ C" G# S          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?! L8 ]2 m4 }+ F
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:4 }4 U" ^6 N( Z. n
(number : integer)
7 k' c% T' M' y: s$ E# M4 q5 ris6 B% b7 D0 }8 n
do+ r) l# Y3 w6 `/ B1 Z2 _5 D5 m. f
   inspect number
' `* }7 @2 j; ?3 X6 h5 a       when 1 then ( X9 @  |1 s* h! K1 @: z
          print "not a prime number"
' P5 Q- r1 z0 j7 `. q  C! f$ F       when 2,5,7,3 then
, m9 ^- V- `" t6 H8 ?4 s: A          print "prime number"
$ o% Y2 i6 ]6 }       when 9,4 then # Y; d; F# o' i. P
          print "square number"
# e: i& W: o$ G       else
/ J, k7 H1 `% R8 j: U" V; s# x9 \          print "no special number";7 G$ d- i0 O# G+ ^8 a" r3 D. ^
          print "or number greater than 9";
/ Q* q9 ]6 f- A/ U8 d. X   end;- B) ]; V  R# C" ^
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, 2026-8-15 08:20 , Processed in 0.015461 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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