设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4589|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
9 p9 w7 r" n0 \" h" w9 g: p, p9 ~; \       Ci :integer; qi : integer) X* H' Y5 R4 \- G# ^  t/ ?
do
! t. `  Y7 e; Z' N       inspect Ci
3 R6 ^  c8 Y9 E# M3 V9 iwhen Ci>0 and Ci <=150 then
. J& n, l8 _# B. K1 E7 u       print qi=1;
: C/ `8 p7 j* M0 u1 Y) mwhen Ci>151 and Ci<=500 then& j8 d2 n- ~4 ]6 ?! n6 b
       print qi=2;
+ l& x! h6 }, `! ^' v9 [8 twhen Ci>501 and Ci<=700 then
) q9 U- c6 `* J       print qi=3;
1 h, u' ?- w- H3 ^; ]7 R7 Ewhen Ci>701 and Ci<=1000 then# }" K6 G2 U: Q! M
       print qi=4;7 J4 b( ]! t5 }' Q5 }1 G* Y% r
when Ci>1001 and Ci<=2000 then
1 {1 ?$ a5 @; Z0 R$ y) z  {       print qi=5;
! O8 \; r5 X- K5 I8 D. O5 jwhen Ci>2000 then
4 _5 }; W* |9 S0 E( Z  I" m7 x; r       print qi=6- h& U) a9 w2 P" ]9 h  M, E; ^
end;
5 i. m! ~5 [% g% U' b& M7 b0 vend;
5 G* P2 t2 F5 R) p/ F+ s# a3 D: |# o% }( k  P* B; x9 D
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
- K7 I$ @8 z' P- o  D          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:' Y# G2 B2 D& _* ^/ l# K
(number : integer)- h- l2 ~* A/ X* Q; q& U2 g
is- }+ p, N: f: s
do6 f  ?% f7 y& L# {# q% q
   inspect number
3 X% ]* u/ c; |: z) i( N       when 1 then . s8 ^- m3 O* F' T1 d$ W* e
          print "not a prime number"
, O* h3 r1 I* r7 f6 n+ p9 [& V! d       when 2,5,7,3 then * w. n0 O$ X7 |* X) @! T) b
          print "prime number"& r3 v9 F( Q* H: b: u0 [1 H
       when 9,4 then
/ t1 i1 k1 C3 s2 E$ @6 k          print "square number"7 }& l2 x& n5 Q
       else7 Q8 u% k8 y; L" D4 ]: }$ k0 F
          print "no special number";# {. b4 i; D5 P2 p5 }; F
          print "or number greater than 9";
3 d" R/ \; T6 l/ p0 u# ~, J, [   end;, F6 F( ~5 f8 q/ y0 f
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, 2024-5-29 10:05 , Processed in 0.010622 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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