设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8825|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
% X1 n- e4 t: p6 b8 \3 Z, n       Ci :integer; qi : integer2 g6 D. l: ^$ Y
do
& c; u. k- k- T) r- L5 f, Q1 S       inspect Ci4 N2 n2 T/ n& N: S, J$ S
when Ci>0 and Ci <=150 then
# a6 ^2 m8 p, F; d6 L& O       print qi=1;
$ t1 B' m! b/ A7 w4 uwhen Ci>151 and Ci<=500 then( R$ i* Z0 L6 q
       print qi=2;
! N& m) q2 ]3 Iwhen Ci>501 and Ci<=700 then
' m5 K8 o; N, c, E0 ^8 p+ m9 H       print qi=3;
1 C) `6 v6 X9 G% E* c- N) {3 S0 rwhen Ci>701 and Ci<=1000 then+ D& Q- f5 z+ z; s: p8 a2 U
       print qi=4;0 j, J) ]0 n4 S7 {
when Ci>1001 and Ci<=2000 then
: R2 |/ X6 J, }1 r       print qi=5;6 J3 M8 `6 q" i- s
when Ci>2000 then
1 j1 K9 B: q) D       print qi=66 U- s3 b2 R, I0 ~, K6 t# Q
end;: s6 @' l' C2 H+ W$ x" M
end;4 ]4 K  m4 H" F9 {. M

) y7 ^$ t3 N8 B) ]* f- U          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
" Z: n6 T( \0 G          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
! y6 Y9 X4 H+ }( v9 b4 }4 z(number : integer)- w: [7 ^8 S' }) n$ g$ e
is
: _1 Z7 `3 }( V, vdo. A( f, S2 g* Z/ y4 e
   inspect number
3 C: O! B4 ?, A3 \' g       when 1 then
3 V4 S9 J" Q, z1 A+ _( C          print "not a prime number", R2 u" v, t2 m0 \  Q1 @0 L5 s
       when 2,5,7,3 then : n# i' g3 E) P' Q
          print "prime number", {! g: x& I! a$ j
       when 9,4 then
$ T2 ]  }8 V& G) v! k. N1 H+ }          print "square number"
+ t4 F0 G/ f/ M6 i' n       else/ J2 S7 }& R2 l, A
          print "no special number";
* I  F9 b1 ?3 X0 |          print "or number greater than 9";
5 V5 r/ k8 L& f! q! t   end;# o: E1 j6 W) U* N* F8 ?" L
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-7-7 20:37 , Processed in 0.012391 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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