设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7793|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is# r8 |  ]. n" ^- o+ W
       Ci :integer; qi : integer
. k- y  c6 G4 u* @  vdo
6 Z7 r$ J: P9 w+ i$ w       inspect Ci
+ p3 z2 ~2 Q* n, I( t7 vwhen Ci>0 and Ci <=150 then % r1 D0 _5 V- S/ A7 s; p5 p# k, c
       print qi=1;
. D) S3 T& _% M1 I) p! c% G, s& wwhen Ci>151 and Ci<=500 then
/ x# W- w% p, _       print qi=2;; l- R/ D/ Z( l, i9 `. o3 P+ N
when Ci>501 and Ci<=700 then" e0 L6 |7 f: x
       print qi=3;
/ c8 o6 A/ F* P# B9 Bwhen Ci>701 and Ci<=1000 then" a6 ?% `5 ~4 |. A3 C2 O, ]  c
       print qi=4;3 G/ _& U9 p; ~$ T, M/ o; l
when Ci>1001 and Ci<=2000 then
6 C; M) m/ o$ y3 c- E+ B       print qi=5;) Y, U  h! I. `  i$ Y
when Ci>2000 then! l7 R, ?, k8 e! l9 {, q
       print qi=6$ q+ y6 h- Q7 [8 S' k
end;5 y! `' Y/ x1 J
end;4 e4 V: G0 R- h
8 P7 I! v6 [* ^$ t8 }! X8 J
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
% ^2 g- S" C+ I7 @3 e( _          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
' d$ ~! D. \0 X. H/ j/ q" z# E(number : integer)
/ r7 X7 O+ P  Y' E2 Dis
6 v0 @) b0 V# l7 |+ fdo& p; `3 l' Z2 I# d8 ~# V
   inspect number7 X5 A; Y3 A9 F% g0 C, k
       when 1 then 4 i& I' x( Y' ?) @# j
          print "not a prime number"
! {% W. X  @, h0 S/ l+ y: |' I       when 2,5,7,3 then $ Y2 x  @, P5 X/ g8 F0 I* B2 M6 J
          print "prime number", I. x+ ]/ D* }) ?- o3 g2 W
       when 9,4 then
4 [, f  ]" {$ I/ Q          print "square number"8 |3 z: v* u; z7 x3 u
       else0 a& O  v. A! M# J
          print "no special number";0 q( r- z8 r/ q6 p$ ~4 Q
          print "or number greater than 9";
7 ]# u1 a' r% N5 a' p8 i+ D; j   end;  f, `% Z" u' J. r" b
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-1-23 20:15 , Processed in 0.018829 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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