设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8793|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is7 I/ S8 s6 x6 t- D1 }
       Ci :integer; qi : integer1 r8 k# V/ I) E5 [1 W3 ^# s9 o( ^
do
. p2 q, L  m+ Y* z/ `/ T       inspect Ci. u, r- z2 l1 S0 W" w5 r% I$ f9 |
when Ci>0 and Ci <=150 then ( ]$ l. r7 C' i( r9 V& d
       print qi=1;0 S) ^+ t4 p  G( v  f) ?
when Ci>151 and Ci<=500 then+ J/ m* B) {+ w; Y( Q! U
       print qi=2;
* Y; E! w8 Y% d+ q; fwhen Ci>501 and Ci<=700 then5 C$ ]8 o& }: \# J9 }3 k2 L
       print qi=3;8 J6 X2 ~8 A& |$ s
when Ci>701 and Ci<=1000 then; N9 Y  W  h' |2 h" b+ t
       print qi=4;- y6 m$ Q6 U$ A3 ^0 v8 G: {3 T
when Ci>1001 and Ci<=2000 then
4 N8 {, C' ], V4 m/ i       print qi=5;9 M* }$ q2 `4 {$ V- f
when Ci>2000 then
  e8 W2 b8 F) Y$ c1 G7 ]       print qi=66 D! j" y+ R% T9 V3 W6 u- t
end;! I& G" y4 q* V8 i! p; B/ L
end;: a$ h. Y, t3 T9 ]# S

& i1 ~2 m2 X, U1 `* f2 A          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?& v( y1 ]) O5 f8 {6 Y: p: g& z
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
; T" ~; k4 x4 P; o0 @' X(number : integer); t) y0 Y& B8 O+ X1 o) w
is6 ]' {9 f9 o* b2 e  A6 m3 R* N8 M
do9 H# {! e7 B$ M  g6 \: O
   inspect number9 O3 A+ j* S/ H$ Q1 `" d& J
       when 1 then
. ]0 j1 v' y( A3 ^( N" B9 F/ G: i          print "not a prime number"6 e) S1 j3 h. ^  K. x
       when 2,5,7,3 then % z9 v( u$ _1 o9 H& K5 g6 ~8 {
          print "prime number"
& B- L& N& @! {. y; S' P3 T/ P       when 9,4 then 9 |) t$ f/ l2 k2 r3 ~
          print "square number"! o. g- |7 c, g1 e$ S0 {* X# v
       else
: a  W9 m" J) j' O" g          print "no special number";7 W9 _; w9 h8 {: f+ t1 K
          print "or number greater than 9";
! A' m$ K% B1 B6 U$ n+ B   end;
* V4 G5 M. \+ h& ]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-6-29 11:29 , Processed in 0.011988 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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