设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9453|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
, m- X1 K9 q! l! C+ w# [- j       Ci :integer; qi : integer* f% ^* {! A0 V+ B
do 1 x  u3 e/ a8 j+ |0 n7 n
       inspect Ci
& Q% o; [, _" M6 C+ Q0 zwhen Ci>0 and Ci <=150 then
( h% O3 i/ t9 g. n       print qi=1;
( W, M. l5 g2 q! C7 _when Ci>151 and Ci<=500 then
3 K8 u/ I) {2 r# l& i# _       print qi=2;
( z. Y2 G/ `! F0 J  v/ Y% c+ iwhen Ci>501 and Ci<=700 then/ a4 \1 Y5 S0 l9 H9 u3 {5 d
       print qi=3;
) p7 O8 M: ]# T. i' f6 zwhen Ci>701 and Ci<=1000 then
7 i6 B1 b5 x3 C( W& g. B       print qi=4;
  Z& L- x: y' T. Iwhen Ci>1001 and Ci<=2000 then& t: d0 p; _1 ^; p; Q- X$ f( S
       print qi=5;
; ?5 _* b- F+ b, ?2 L% Z7 z# Rwhen Ci>2000 then- ^7 x* C; l/ E- w
       print qi=6
# |# h1 Q- ~1 yend;
( M( f* V% j& _end;
* |6 O; \* G1 s! S6 X& a& \
$ K' G$ _% d! V* b- @  [          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
' F0 v  h2 _' \$ E' S; e! P, Q          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
$ Q! @" t' w: \$ G(number : integer)
1 h. d7 g  C/ f# i4 p3 J7 Qis
2 O8 X# K; O  i: i; Rdo
: G; A, |& ~7 G   inspect number
  A) V& B- I4 `) H$ r+ M       when 1 then
1 t% {+ l  }. r          print "not a prime number"
! m7 p: l' A( ?       when 2,5,7,3 then
& E0 T- J/ j6 O. f0 a" X          print "prime number"- I9 f0 c9 i& b( C0 G
       when 9,4 then
2 C# x) I2 e5 G          print "square number"; U  @" z0 w( g. c" i
       else2 Z+ A1 I: x# j, ]& C
          print "no special number";$ k4 ^! ]1 i, I  D
          print "or number greater than 9";8 j) ~/ _. p" x: }
   end;
: A9 n& T+ A1 ~& k0 d. O9 Oend;
 楼主| 发表于 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-20 01:14 , Processed in 0.013757 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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