设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7867|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is% E% H9 s/ K3 O
       Ci :integer; qi : integer( D$ z9 b/ V  M$ e% o- s4 y: `1 a* T
do 1 S6 d; ?+ s+ P' |8 ^; K
       inspect Ci( p# q+ o, P& \- M! Q. v4 O
when Ci>0 and Ci <=150 then
" D9 q7 b- u! Q9 j1 W' Y1 |       print qi=1;
1 V- s3 ]" B  X8 j  }) X! C7 Owhen Ci>151 and Ci<=500 then
3 q5 H4 M$ W, ?% t  M7 u. U       print qi=2;
" D  I+ [7 O2 L" Xwhen Ci>501 and Ci<=700 then
$ U" |( A+ W9 W       print qi=3;
4 `2 H+ s- v! dwhen Ci>701 and Ci<=1000 then
0 x; y5 D: L0 J. [- [! a, P  ]       print qi=4;+ H3 _: p4 D8 \, w/ C
when Ci>1001 and Ci<=2000 then* D' Q* X( ]" |7 v1 V
       print qi=5;4 S4 n' P! t) }; S( ]
when Ci>2000 then8 p% B, {& q$ d
       print qi=6; a$ p  L) M" q8 f
end;
4 J" D1 x- h) U# b3 Aend;
; i! M' J# X6 t
8 \0 M. t- c2 Q1 c: s6 d          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?4 H6 x6 E1 I  }; e8 R
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
! _2 r7 q" B5 Y! N* [; u7 F, [(number : integer)  I7 t, ^4 K: i1 }! G  W8 a
is
+ E* l. ~  d; E) B, ]' A5 X! W+ F* Qdo3 |: |: o# z5 ]( V1 z- p, u: x1 Y# _+ g
   inspect number
" b& g/ t6 T# Y  e: X       when 1 then # y- y) ]+ G9 r" r6 H" J
          print "not a prime number"! x4 F( ~+ R1 N- l+ f7 k5 O" ]  I
       when 2,5,7,3 then
& k7 ?1 c2 M8 Z/ z( V$ m4 F4 f          print "prime number"7 X/ X8 [8 }4 g0 t6 x1 g
       when 9,4 then 6 g( x5 }! z3 _* v/ l4 U; R6 I
          print "square number"/ }0 W( F  E% _. R
       else
! @) k% e: b4 [          print "no special number";0 n0 ]' q2 k; q4 S( e, c" t
          print "or number greater than 9";9 t# F1 N/ x( V4 y: _
   end;
# s$ R' _' i* j% b, 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-2-5 19:53 , Processed in 0.015478 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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