设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9363|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
5 k4 G# u+ l. N       Ci :integer; qi : integer
, }! a6 ]; m7 J- w5 W. {do
0 E1 F+ j  H: K2 R+ I* G6 h       inspect Ci7 A, I; K" x% T$ `6 V
when Ci>0 and Ci <=150 then
0 F6 S( Q- I$ f% y       print qi=1;3 B  C1 H: S0 O7 b7 ~
when Ci>151 and Ci<=500 then* Z+ E2 S- ?9 K& K
       print qi=2;
! Q5 ^7 [0 }( t: _; L* s) G9 Awhen Ci>501 and Ci<=700 then# h; l6 x! c6 G6 @, T
       print qi=3;6 L8 F$ [0 o8 ^
when Ci>701 and Ci<=1000 then) i% U. A6 o4 {, l
       print qi=4;
- ^2 S5 Z9 b3 ^  ~, hwhen Ci>1001 and Ci<=2000 then! v! I. \; A* C; }8 l. I8 y& ]- X
       print qi=5;4 Z! Y# g2 o+ C  I; c
when Ci>2000 then* O( g' ]; r$ D6 u$ k/ x& Q* ^4 x
       print qi=6: y2 g, s' y8 [- |( v
end;
. j. Z# H2 s$ |) |6 q& @' Aend;
* P* t5 U+ L" T: O# i
. ]; X+ p& a4 p; L9 t          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
5 U7 V; ]- ], B8 U/ d          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:; q" t. e3 N, X" b1 y8 L
(number : integer)6 C2 k) n6 e2 J3 A9 G
is2 k: i( c! ?( k5 N# x4 V
do
  [# t+ Y" a3 h& d   inspect number9 `$ ~( d' O, Y0 c" {
       when 1 then
; O6 ?1 o3 Z3 C) x          print "not a prime number"5 J* v4 {+ S2 b, J1 n) G/ M  Q( W3 o
       when 2,5,7,3 then
+ t; q$ b/ }+ ^( L- w- B  I1 z          print "prime number"8 m/ Q( j8 x$ e' G4 s$ U- l
       when 9,4 then + j$ ^! j8 ^+ ]
          print "square number"  k  y3 |' \9 q* f* T# h- Y  x( U5 F6 x
       else
. P- `3 Q8 a9 Z7 g- Y          print "no special number";" r1 M8 s% w7 f! I9 U% w
          print "or number greater than 9";
8 g8 |' n0 \) m   end;; ^9 e: d0 j7 |& @( Z) i9 u  E% W
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-9-8 15:55 , Processed in 0.022129 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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