设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9144|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
& x! U( K' m4 o: Y4 o/ t  D2 t5 X       Ci :integer; qi : integer
) v1 h9 \, k3 R4 ^do + B0 @5 ~1 b+ ]% `% }
       inspect Ci
3 T* @+ i/ x1 F2 S4 T8 @5 Xwhen Ci>0 and Ci <=150 then + e* X- b5 h% ^, X) v) [
       print qi=1;
$ x2 S7 v! E' u; M+ H' ?( fwhen Ci>151 and Ci<=500 then
  }) u! U/ y" U6 V" e       print qi=2;7 c2 z, I3 e& Q# G
when Ci>501 and Ci<=700 then
1 a9 U) p0 h8 }1 C0 V5 s       print qi=3;
' R6 {" C  x9 Z$ s4 Twhen Ci>701 and Ci<=1000 then/ I$ |( U5 Q: {% w& {
       print qi=4;5 l. b2 X& k8 V, A- `& k. d7 i4 T
when Ci>1001 and Ci<=2000 then+ S5 X9 `) f2 n* X8 B8 K
       print qi=5;
* S& o, R( B# u' Hwhen Ci>2000 then! m! p) C7 x1 {4 c
       print qi=61 J+ g  ?( v9 h0 I. V
end;
3 v1 i9 t2 k; W# T4 ]end;, n9 k- t; e+ d+ ~

/ ]( O5 b  H4 q; i! I8 B* h( @          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?/ Y2 a2 j" I+ e1 v& u1 N) j
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
! x! W3 W, o2 l( U4 v. `(number : integer)
& T# l+ }# Z5 u6 I6 C2 D3 h1 O' ]9 tis0 R7 F- u" C  ]0 Z. @
do
/ F9 V* }% v$ t: V, y7 f   inspect number3 H' i! j9 b# g9 W8 u5 U
       when 1 then
5 O1 P& q3 w. Z( x) n# G& W          print "not a prime number"
$ m2 r: O2 Y! i! D4 P: a- i       when 2,5,7,3 then
( r% U% E0 D( C2 B          print "prime number"0 g1 R, X* Q" ?* [, j# c0 a8 G1 M
       when 9,4 then 7 P+ V0 k5 k/ w# z* p7 m* R
          print "square number"
5 y; ?! i/ J& S8 d       else
7 @+ z( p" {( t  U- E' Q& w          print "no special number";6 O$ L+ H" U& W
          print "or number greater than 9";
8 V* P; r+ S; L   end;
! b# b" b2 ]6 H6 ?8 P' e) x7 |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-8-4 00:33 , Processed in 0.018680 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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