设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6495|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
1 e8 R' {: `! |5 T0 j* D1 i       Ci :integer; qi : integer
4 R# ?1 {" ^' y5 Ydo 3 O' r. y, j  f  b
       inspect Ci! t: p9 \  _: o7 {8 |5 I
when Ci>0 and Ci <=150 then 5 F  o0 q4 L; g4 Z+ G1 _
       print qi=1;9 {0 V, N% N+ \( {- Y+ x
when Ci>151 and Ci<=500 then
# ?3 d1 p- n5 y7 G       print qi=2;
2 I% w* H" g  K; o/ M" m  Xwhen Ci>501 and Ci<=700 then( i* v# A0 c4 h: Q$ K
       print qi=3;
5 c' n- g6 l, g; i  k1 W* Z8 {when Ci>701 and Ci<=1000 then
, |4 }5 F3 C2 D1 p+ |7 R0 F; A       print qi=4;
1 }  O3 o1 j2 {+ vwhen Ci>1001 and Ci<=2000 then6 q# v, d( F& h$ p' a+ W% W
       print qi=5;
: X# i8 {1 i! x. awhen Ci>2000 then
# ^# Z" p0 A* _0 c- \       print qi=63 q: M& Z2 \6 X  [. @) ^
end;: g& S: g/ O# F
end;* Y- ?4 ]& v. P9 t" E6 d3 d8 B) P
6 u5 D$ ?  o- J4 P, A# O  q
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
2 {  {6 l/ H8 Z. n3 j" t          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
; H7 Y5 [/ w- E& z3 d! j(number : integer)% H# T& I7 p: T
is; E( q4 _# U" J
do
3 l" F9 C6 ^: a- P  L! N' A   inspect number1 Z1 S9 }7 [# l' ^6 c, o: A7 b4 k
       when 1 then
: T) }; k2 J' q* h) b: }          print "not a prime number"; ^/ F4 g/ o' [/ A. G3 B
       when 2,5,7,3 then * Z5 h! e9 u' q" G$ v
          print "prime number"8 H7 g8 v8 L$ F% i, v& C
       when 9,4 then
* q* D" _7 b7 V; k          print "square number"# X; D; B! I; G4 ^' Y6 G& V  F
       else0 u* P- u/ Q) O
          print "no special number";; ^' Y: L; P0 A  @" C7 u
          print "or number greater than 9";6 m5 u% S+ i& m7 z0 A4 q
   end;
, J" ^: d( d5 U( u8 _- g8 send;
 楼主| 发表于 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-5 08:31 , Processed in 0.014756 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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