设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8020|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
4 U4 p6 B' G, H  ~* M& c2 i       Ci :integer; qi : integer
# C0 \' `$ Z' i: a, Gdo
. ~# N; k# _8 ?& T; R3 ?6 P       inspect Ci: c$ {9 x( e& `
when Ci>0 and Ci <=150 then # t4 ^3 l1 p+ X- ]1 A/ }0 f
       print qi=1;
! u3 S3 W& H3 k1 G* a' X( W$ _! ^1 mwhen Ci>151 and Ci<=500 then
: q6 T; ]& S! W& V# h8 N       print qi=2;) S1 X- M7 k4 w$ r1 f
when Ci>501 and Ci<=700 then: P) ?2 d. K  r) g/ ?
       print qi=3;% o9 k- K- ~/ k; x8 g, `
when Ci>701 and Ci<=1000 then
3 ^" o  B3 C# o       print qi=4;( n- c3 |$ h/ `
when Ci>1001 and Ci<=2000 then
5 h2 I! n3 w& f  P       print qi=5;
( ?5 E1 J0 @" x! Qwhen Ci>2000 then, a2 x, W" M9 U
       print qi=6
- r2 I7 T! m4 [; Z7 ]* N* tend;+ W4 U- A& T: _& `1 ]
end;
0 v: i4 O7 Q8 r; b
  {% k2 ?' A  X, m          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
+ K& E+ I8 U% C# f2 ?" P. B- |2 b          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
& q; J* H2 V- N! p) l(number : integer)
9 B" c: G7 h( x8 H# V* Dis
. {" T% C1 Q3 f& m! u+ Ldo& H$ T+ `6 O+ a/ ]- @4 t/ s6 P
   inspect number+ M- c; |% X* R0 F( g
       when 1 then 0 _7 V2 F4 w) c
          print "not a prime number"
, J* V1 T: d( b, X9 s; X       when 2,5,7,3 then
; {' [$ |" f5 e7 d" S( T6 v          print "prime number"# ^9 P6 G+ T% W, r+ c- k
       when 9,4 then * j0 n' o' w; c% T% |; w
          print "square number"
' L7 x+ I, ]% n4 i9 r; {. ~       else
4 G" s5 `& o& j* W9 f! S5 f          print "no special number";& ]* f" y* W* U$ p0 g5 Y+ @
          print "or number greater than 9";( E0 D, j/ N' e! K* e# b+ s
   end;
1 V5 o. @5 N. ]4 H7 w( Kend;
 楼主| 发表于 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-3-5 02:01 , Processed in 0.018958 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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