设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8141|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
0 H% V3 \) a3 P* Z       Ci :integer; qi : integer. `% d7 g& s) j9 u
do 7 A+ ?2 N' q7 s7 t. E1 _6 D( o6 ?. l
       inspect Ci
" u' I6 W" D6 D0 c8 F* R* Gwhen Ci>0 and Ci <=150 then
+ F" w. \/ O+ Q- X) [) N4 |       print qi=1;- [+ y5 e/ L  h
when Ci>151 and Ci<=500 then
+ n2 t1 W* ~/ x. i; _       print qi=2;- B; B: C% k, ^  f
when Ci>501 and Ci<=700 then
5 R3 ]( `" h. y+ o6 F! ^) E+ x       print qi=3;
5 R4 a9 A# O- |( Y% E5 ?# P4 e! `when Ci>701 and Ci<=1000 then
+ C+ B+ `4 T: k# @1 s* Z. o       print qi=4;& @3 Q) h2 y/ ?2 k" Y2 a# C+ G
when Ci>1001 and Ci<=2000 then/ S( i8 ~$ ]" h( }" R  R
       print qi=5;
% u1 @( e) _% l1 s% F- t$ owhen Ci>2000 then  `( B& X  t- n  n0 D
       print qi=6  H5 l" w0 f( v; [2 t
end;: Y' Y1 g% ?. Q7 |# ]
end;% r- D: D- X$ q- w  q# {% D. H

* Z* \' |4 t$ G9 k( N, x$ y: J  x% r          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?0 q7 ~0 A2 V' o
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
& f  E3 y+ x% u- l9 m(number : integer)$ x  `1 A- U& l1 E& N3 a) \/ i2 E
is
8 D# P6 J- C& Y' Cdo
$ u+ A4 e$ r8 n$ c; ]. S   inspect number  _. J8 E9 ]  @' J) j/ `
       when 1 then
8 z/ e" |: @" F. Q+ ^* A& y          print "not a prime number"0 \- D, n# S. w; j) {: f8 t
       when 2,5,7,3 then   c, ]9 D% C% x# H
          print "prime number"+ H- z8 i6 |: u7 t$ j
       when 9,4 then 4 y- s3 D  b- |5 C0 h9 i
          print "square number"2 t; F# C+ q! A4 f* X
       else
; m; Z, U- ?3 W          print "no special number";; h5 z! f8 a; L: q8 {! u& O
          print "or number greater than 9";
5 D' ^- m# n& V8 D' I   end;
' p6 m' q, g/ a/ S5 Tend;
 楼主| 发表于 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-3-26 07:22 , Processed in 0.017814 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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