设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7382|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is9 w7 z+ B0 c5 z! n
       Ci :integer; qi : integer
* {/ `0 v: b- W7 ], S6 Kdo
2 n: }6 h6 w$ Z8 C7 V$ \       inspect Ci
) t- b* v3 T5 z" o, O' Mwhen Ci>0 and Ci <=150 then
2 e* ^  I' j+ W( z# C! U       print qi=1;
  Y, C% p# x0 m2 \: h3 w" K+ Vwhen Ci>151 and Ci<=500 then
/ b( H9 A3 L2 e4 i       print qi=2;
: _- d. o8 {/ |& G6 Rwhen Ci>501 and Ci<=700 then: B0 w  u& E9 r% u
       print qi=3;0 M$ F6 M7 r: q+ o' q$ K8 O
when Ci>701 and Ci<=1000 then/ o% O+ C. y- {
       print qi=4;
: I% B1 F, n+ [/ `; x. O* G2 lwhen Ci>1001 and Ci<=2000 then$ E% m, a& K8 k7 r3 s' n
       print qi=5;
. q/ `9 ?3 k/ B* Y  O6 h( ewhen Ci>2000 then
3 q; }, i' l1 Q, f       print qi=66 D. R! a) U5 @* @+ {
end;# F: U' u* E1 U6 e4 T7 O6 r
end;
0 {- O  y: s8 y! l0 j8 v. T" t8 f- I2 r. I
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
+ C# |& {! _8 g4 l3 l$ K          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:3 A4 H# `# o8 n/ g1 W* O1 ?5 D$ U
(number : integer)( n. ^$ e3 a- ?( F; n
is# C1 e/ b" G  G+ n
do
1 S( R) A- U8 C: j' L# }1 p$ X   inspect number
+ q* Q7 @2 e7 Z9 H3 W5 `, K       when 1 then
" s% d& y7 k+ q4 I          print "not a prime number"0 n. |1 v) t* N' r- v, W
       when 2,5,7,3 then . h& X' m5 ], p6 V. U
          print "prime number"7 B( g# N4 K! b- s( Y
       when 9,4 then
1 C& r8 J% p+ Y1 I0 N, Y          print "square number"7 I: k2 A: o! E" Q, W
       else
  X. G4 L4 }1 x: `( q+ A. P2 V          print "no special number";) I" A2 @; {' D
          print "or number greater than 9";% A: c: S9 H5 G5 |) J( d) T/ S
   end;, I: w. E" f# W& E
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, 2025-11-15 13:12 , Processed in 0.016616 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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