设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9414|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
2 T: i; q6 P* v# d2 S       Ci :integer; qi : integer% q" [1 n8 e& R1 E1 x: q& T
do
2 ~' g: s) r1 l- x6 n8 _       inspect Ci6 n9 ]1 ^) i* |5 Z! P- w+ P
when Ci>0 and Ci <=150 then * u9 x/ `* k4 U# N" a% n" I
       print qi=1;' Q+ v  e/ C/ r, q& U+ m- f& j( j$ ~
when Ci>151 and Ci<=500 then, z1 e, T5 w% B7 a% H' F
       print qi=2;
- M$ v5 ^; k( B$ O) k2 jwhen Ci>501 and Ci<=700 then- i5 f: t: B4 x5 y
       print qi=3;% \9 y4 H' d4 h4 |
when Ci>701 and Ci<=1000 then
9 E# A. ?' q' \5 |1 {" O' D       print qi=4;/ H! G/ y: N; L' @% f! k+ ~/ x
when Ci>1001 and Ci<=2000 then: d2 M$ Z0 K$ L
       print qi=5;
) D: K! D$ @; l5 J+ pwhen Ci>2000 then
0 |$ L6 I2 P# ]" n* q& @       print qi=6
$ d& ~, _/ E$ F* B% u3 Z* Yend;
) \4 T# C4 r1 r; U! Z0 w& r$ m: Y9 oend;
- ~& e0 Q# Z/ M5 v+ X
8 H& O+ v3 Q# H4 c& y4 |- Y          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
2 |" I3 T: c$ _: t6 z- j' Y9 V          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:% R+ R) u6 R9 l
(number : integer)
  l' M2 s7 s5 K8 f7 v+ @: cis
, R, |. E4 A/ v3 Y/ [8 g6 ~do
, L) Y) ?) }$ E3 _   inspect number
! W5 ^/ R" p9 Z/ C8 r  w  {% i% {       when 1 then - z4 b- Z0 x4 [/ \. @
          print "not a prime number"8 B$ _7 W1 f/ ]( E3 u3 z. W! r
       when 2,5,7,3 then 9 U1 S1 r5 n2 {& d) J0 d  S; e
          print "prime number"
' A0 t" D- q8 P  a  M       when 9,4 then * g$ o& {6 B" [
          print "square number"; K2 {3 F0 J3 ?- z. p' X" G6 H7 {/ o
       else
3 t& j0 o- _8 W% P# e: G. w          print "no special number";5 N6 ?/ n- r# ]
          print "or number greater than 9";2 [$ b, Q6 w) H1 O& D
   end;
& J, \: F2 C- k: V2 tend;
 楼主| 发表于 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-9-14 22:57 , Processed in 0.012983 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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