设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8777|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
! v; Z4 }9 T) P# u8 D5 `% ~. z       Ci :integer; qi : integer8 R1 d: A* Q! P: \, x
do & g4 B3 y  \; P+ l+ [1 F7 P
       inspect Ci7 i: `0 [) F! \3 e" D0 Z
when Ci>0 and Ci <=150 then 8 F5 k6 X2 H3 L) [6 T7 x
       print qi=1;
- _# e+ W8 B* f+ |when Ci>151 and Ci<=500 then
8 V1 T1 M# o! U0 Z       print qi=2;8 |. x8 T0 `8 l; k
when Ci>501 and Ci<=700 then
. v4 @( F+ p8 O5 w. {       print qi=3;
" ^  S1 v8 ]( E3 g. I' Q  vwhen Ci>701 and Ci<=1000 then0 ]" i/ ^4 o, C0 `. L+ G2 j, q! ^
       print qi=4;
! h! F5 T5 I0 Owhen Ci>1001 and Ci<=2000 then* Y; ^' x# ^+ [
       print qi=5;0 z( B8 U' Q, x; t
when Ci>2000 then* o  @* X6 Q' ]& l/ d
       print qi=64 k4 v2 K8 {( A) f5 M' {2 W, g
end;. Q8 `* R5 p3 M- O0 w, @
end;4 Y+ g* C4 \% L* r- ]

1 D$ \0 B' g6 l) N          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?& h6 y% p8 ^$ _! D
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:+ v/ A5 H0 y) r# ]
(number : integer)( c3 K% M0 f( j1 h
is
: W0 a- S# O! Ado. a" j$ J# B- A; G8 A) G- x
   inspect number
! ]( j4 j4 A, o4 F8 H       when 1 then
# A0 R/ b7 w* k: q/ M$ A/ L& z          print "not a prime number"
4 m1 A; @' y( U0 n       when 2,5,7,3 then ; q  l% j% M% \+ x4 \. l
          print "prime number"  m5 k7 Y9 N: V& f# ~3 h" Z
       when 9,4 then 9 f% A# g& T/ }3 h9 H: u  S3 s3 ~/ @
          print "square number"1 I7 u* U+ i2 y! m4 r
       else% U& _# S9 |) D
          print "no special number";
( Q  b6 u0 o* v* d          print "or number greater than 9";
$ m1 A& o: m) J: R; n7 x! R, }   end;) f/ l- B: u  X: e" e8 D) v! c
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-27 08:15 , Processed in 0.013892 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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