设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8451|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
5 W* F7 t  D- V- Y" U  z       Ci :integer; qi : integer
: E6 Y! G" C* U- v! \( m) j1 |1 Sdo
( S9 P& @4 H  N, |       inspect Ci
; d0 S, o3 Y2 `6 {1 Y9 F# r) Cwhen Ci>0 and Ci <=150 then ' ^8 C% X# S" F' t0 ~5 ^) i% c4 c# y
       print qi=1;( D! _! S! k6 G- H: n
when Ci>151 and Ci<=500 then1 b; V2 c4 r0 ]" H) n. l" n
       print qi=2;" o  v% M: G- |3 ?* ]/ l# G
when Ci>501 and Ci<=700 then% L+ \6 ^" q+ `  _% A
       print qi=3;
0 f' ?6 v8 O: D4 d2 p, Zwhen Ci>701 and Ci<=1000 then2 \9 a- h$ X4 H8 j9 P# q
       print qi=4;- d: i! L) i, i# B1 ^
when Ci>1001 and Ci<=2000 then
1 N) I/ L" i3 {, u: W       print qi=5;8 [9 Q9 i7 _+ x$ O7 X+ s
when Ci>2000 then  w, k; M, Y) i  I8 O4 S) c
       print qi=6. v: \2 C% P$ X' }* f# C
end;
2 J# ^' W. B  a6 T8 bend;
8 S7 }& B; j( t2 D
, `$ [9 M9 R$ d: y          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?3 _4 g- R  F+ W$ L7 A  W! {! W
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
( g. B+ j3 c4 E* q  V(number : integer)
6 I0 L* E; d- ^) m" j0 k8 \is# H5 D7 q. U  e- i
do
8 C, v9 t2 w( y' _6 _  Z* g   inspect number- _8 O, s, S4 |7 [
       when 1 then
/ a& {: L' I/ P$ A" ~  q/ ]          print "not a prime number"1 Z, r5 l5 P( H7 v
       when 2,5,7,3 then
1 v& W3 F* ^5 L          print "prime number"# O$ _2 }; ~1 t% @# `1 Z: W. q
       when 9,4 then
4 p4 F6 C" Z+ i# Z3 u) }          print "square number"
1 B+ J& ]+ g% T, [( V* _       else, h. `9 H  u9 t; X* d
          print "no special number";- Z) C9 [3 b6 s/ K2 {
          print "or number greater than 9";3 o6 N3 c8 n( O+ @0 U
   end;
8 Q5 T9 O# Y9 h! W. Xend;
 楼主| 发表于 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-4-28 07:17 , Processed in 1.642511 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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