设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9200|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is0 F/ H+ \+ a$ v7 g3 A
       Ci :integer; qi : integer8 M" m1 B7 r! o% Z/ }
do * q; X: _% X' a' p; J" y6 W
       inspect Ci8 F0 g7 b& {& L7 f" i( x
when Ci>0 and Ci <=150 then
+ c# e6 C* j" l) m  |       print qi=1;
9 q* ~( P! {1 E' c8 b% owhen Ci>151 and Ci<=500 then
$ W! A' D$ t  K1 \       print qi=2;
9 F8 T4 @8 Z) Z7 x% }2 N8 G9 Gwhen Ci>501 and Ci<=700 then
: F6 k1 Z: Q" l, p2 [( c: y       print qi=3;2 l2 s$ L/ r, d" s! ^% _
when Ci>701 and Ci<=1000 then
/ S$ k( l/ C" L  n. @6 C       print qi=4;
' d( m" T0 c' E4 [  x2 T' ]$ _when Ci>1001 and Ci<=2000 then4 [( ]" ^  j, j/ h* B) T) L* H
       print qi=5;
: k* N9 o9 G0 u$ k4 M* x. Kwhen Ci>2000 then6 z; X8 W, N* y1 M- w9 I! `
       print qi=61 p' y/ W; v$ [& }
end;
: l/ f. C3 U5 c3 u/ s$ }end;
1 d# w; g" \* U! Z" @- B* `: J4 N) q; O+ W1 p/ n
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
$ b  Q- G) R8 a9 {0 E0 U          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:6 D5 c) h" C9 d' ]* V7 a0 w' r
(number : integer)5 m6 W: P8 W+ a; J( y, I0 s& @
is
0 Q5 c" x  R' P- H9 |do  a0 f6 B. D! f- L. a4 A" |
   inspect number
) N2 ?( W, @: i1 _       when 1 then ( y4 j) l9 s8 {
          print "not a prime number"
* @3 b8 z- J6 k       when 2,5,7,3 then / o& ~: H  q6 M. j
          print "prime number"
' o6 E3 p, u1 q, e: N       when 9,4 then
$ p' {: L' h# V/ ], t          print "square number"' U8 m7 n9 m; g$ h5 L- ^, t
       else
- m% e; {8 G& b          print "no special number";
, Y# h2 D$ l5 U; h0 Y  h          print "or number greater than 9";
$ l* \& s8 g/ ^   end;* d5 `5 U0 Z$ i7 _3 h5 X
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-10 13:48 , Processed in 0.015812 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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