设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9510|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is6 v1 q& o8 i, a! }
       Ci :integer; qi : integer
3 |8 `$ @6 M6 f0 M. ?do
, e3 [; O$ C1 @       inspect Ci
; q" d. O; o7 l( vwhen Ci>0 and Ci <=150 then
0 r3 v2 b, B1 Y. w" i5 ^       print qi=1;
: z" R' F  T: swhen Ci>151 and Ci<=500 then& j3 N% ]( K) n* @( u
       print qi=2;
7 L/ C. j5 o- I+ R; o! F; Kwhen Ci>501 and Ci<=700 then  X+ ^3 l: W. i5 ?" \$ n
       print qi=3;
/ g8 ?2 y) ~* J$ F- s$ p) j7 twhen Ci>701 and Ci<=1000 then
  Q* O; w7 d5 {6 @, G$ {( G       print qi=4;3 `" k  s' t: }7 R0 z  o
when Ci>1001 and Ci<=2000 then4 `! W; n% P  p0 S* K- c1 d1 m& F
       print qi=5;
4 G/ A3 K2 a) s8 N+ ^6 Nwhen Ci>2000 then! v" ^( S$ h% b* N
       print qi=6
$ B/ D' k( \. {. i  iend;
7 E# B& M* ~- W3 r' _2 yend;8 m, p9 m5 F3 }/ ]* M  V

) p- T6 h! K* C6 N& J: k+ n( z& W          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
/ V- J! s- W: Y          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:5 X$ Z6 f  s- ?3 j; ]. [2 N
(number : integer)
- P: A2 ?5 C/ U5 |is
% w7 X! E1 g" P9 |0 L& odo
, c' t. z- @' H   inspect number6 q+ u: u% Q! k
       when 1 then
; c) G; ]6 d7 r0 l2 ~* R          print "not a prime number"( j  a7 A' ~: h# `! c  H% @2 x4 Z
       when 2,5,7,3 then
! t9 c% w* D0 w% F7 k, c- A          print "prime number"( K. j- Y2 h2 k3 a
       when 9,4 then 7 R2 o9 L( b# L& @/ t
          print "square number"7 k, @7 f- m( g! D9 O
       else
1 ~. I" E( C: G) Q          print "no special number";
8 l) `* i9 h& P  M  N          print "or number greater than 9";
9 a* `( c% X- A   end;
  b" c. ?3 d$ i8 _# `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-23 23:36 , Processed in 0.015122 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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