设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6566|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is! g! a+ {* C% j% y
       Ci :integer; qi : integer
. u( c; d3 R" E7 R6 Y, Q1 }do
; m3 I, s5 c& {% H3 t1 v6 m# O       inspect Ci9 x0 C; m' a* \' C0 a0 q" E& k6 i
when Ci>0 and Ci <=150 then
' W5 K8 y- ~. w6 `  l; l       print qi=1;# w' u& P, V& i' g. ^6 o
when Ci>151 and Ci<=500 then
; G$ e. `4 u1 b/ g4 K       print qi=2;
8 {, i. ]: u# l# c; swhen Ci>501 and Ci<=700 then
/ [6 _$ Z2 `9 b# V, ~$ E; e, v% s       print qi=3;
5 S  k6 q9 B  r2 `when Ci>701 and Ci<=1000 then
: k  j. U" q* _1 V       print qi=4;1 g1 S( P# w( ~
when Ci>1001 and Ci<=2000 then' K, }2 V0 t" k( p6 C
       print qi=5;
! T! D: q" a) u; q# Y( ewhen Ci>2000 then+ K6 v5 _* q% H" c6 y* \) {
       print qi=6. `4 G) s% p! d, o
end;
; ~' ]4 b; ]- @' o! Q* bend;1 X' R3 q8 `1 i5 ?& ]
" S* r; r* K/ @. b9 ~0 r& E
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?: s9 y) H- F  q) j2 N; Z+ @( k
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:! w, w& Y) F0 w  h6 Q( f! S
(number : integer)
6 k' i' _3 M" h& S9 B8 eis- d6 e/ _2 t( R. ~
do  q" ^& m# F/ r, D( a% e! S- a
   inspect number
+ A' d2 U3 y' t! f+ u+ O       when 1 then . q( s! u% k8 S: I5 |8 a
          print "not a prime number"
3 V  x( {# c' N3 k5 F' p( L5 C       when 2,5,7,3 then 7 \) Z$ g7 @- }# I
          print "prime number"
9 a% O! n+ y, Q1 ]       when 9,4 then ! o2 `/ J6 J# |# z8 w: r- n# o
          print "square number"
: D* Y! {* u( Y       else
8 c# Q& ]) i9 c8 H3 U* f          print "no special number";- G) P, x; ?! H9 l1 {0 q
          print "or number greater than 9";
" }% @  N8 H# T: \   end;
5 s& J6 g* Y: ]0 qend;
 楼主| 发表于 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, 2025-7-12 18:44 , Processed in 0.014018 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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