设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8466|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
3 o! b, p' N. M! M: Z* u8 T       Ci :integer; qi : integer
7 U  u5 J. ?- a$ T1 {! s2 sdo
- n" g7 b8 z3 r       inspect Ci
# k( F) ~9 [( L% Z% |2 Kwhen Ci>0 and Ci <=150 then   s  `# Y6 Q* Q/ a& b
       print qi=1;: e! X, \$ s) B$ @6 k! E
when Ci>151 and Ci<=500 then! U( d7 c* @3 V7 P' e+ ~
       print qi=2;
: T9 }6 o' z0 b" x+ Bwhen Ci>501 and Ci<=700 then5 b8 f0 q0 |6 ~! X, h
       print qi=3;# y) V5 w1 S. O) r
when Ci>701 and Ci<=1000 then, B& S' Z4 f( S3 u1 Y/ q6 `
       print qi=4;
$ C: ?9 H- E% F8 I. qwhen Ci>1001 and Ci<=2000 then
' R/ N) f: S; }" u( b+ E0 G       print qi=5;+ R/ E6 t8 D1 D
when Ci>2000 then
7 ?$ r; g- ^: O, p       print qi=68 m/ r) T! E7 T! D
end;
# ^3 }# G0 C$ aend;$ T% v/ P1 w, h4 d
, o1 B7 w; Q+ N; T4 l4 K' Z
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
6 X* n) d5 K) ?9 e# |          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
2 I: y& b/ Q; c# g& q5 J(number : integer), Z% {, e4 p2 M# i7 h
is
& I! y3 g$ y3 {do0 O* J# R) K7 x
   inspect number3 R, z1 t" v/ w9 F& e
       when 1 then
6 d# d: o& c0 d5 A3 k: n          print "not a prime number"
# j/ \1 S1 T/ Z) \4 B" N1 N9 O+ j       when 2,5,7,3 then
6 M6 S, h; v+ W2 t          print "prime number"
' @# \1 i+ C7 L* H. Z2 U+ K       when 9,4 then
( j1 K8 M" H" d  z          print "square number"$ ~; f' P# f5 _: t
       else
. j2 i$ _# B1 B1 S$ K: h" A% D& S          print "no special number";# O: ]! r& f, h) d7 ~9 [0 q
          print "or number greater than 9";5 \/ w. c: b, b4 Y! {5 h$ [
   end;
* G5 A" g; e2 U- b: S: p: Y/ lend;
 楼主| 发表于 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-4-29 14:00 , Processed in 0.016192 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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