设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7678|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
1 ]- f% i6 K( I. ^  ^. z* [1 _       Ci :integer; qi : integer; ?7 Q9 f* C, z" |
do
0 t5 W: ?" ?0 ]6 n       inspect Ci
( {8 k) k# [# `1 B# Y1 V3 l3 [when Ci>0 and Ci <=150 then 2 x  b( d; Y+ K
       print qi=1;
- F: q; M7 q8 S- _6 L1 w  z0 ewhen Ci>151 and Ci<=500 then  J% `: i# k! |# u
       print qi=2;
4 _3 y6 H9 G/ l4 \6 T) Gwhen Ci>501 and Ci<=700 then/ y" ?' A4 u0 l% ]
       print qi=3;
  {  Z9 Z! ~9 j4 z' w  a- z" K6 \# dwhen Ci>701 and Ci<=1000 then
, j$ |8 h, z1 r1 ^' A       print qi=4;/ S4 f8 o: W7 Z% E7 U
when Ci>1001 and Ci<=2000 then' y+ w3 o6 t) B/ p' m& F
       print qi=5;
( F8 a6 U& x1 ]* n5 Q" ?when Ci>2000 then' ^- E, {+ ?8 k; n& B' Y: S) |
       print qi=62 n& ?, S5 ?* ^3 d6 h4 R+ O
end;, D* d" X( f+ G' P$ b+ T
end;' T! o( C/ j/ J: u. u+ N
7 B$ [7 F: W( x( V+ k% [
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?% ]/ Y% U6 [' @0 B& N5 \
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
: [6 D! _4 Y8 q: B: m# r(number : integer)
0 p8 B1 X( S1 xis8 g6 V4 X. s. B" w3 A
do
& Q- T* n% j% E4 F7 ?0 F7 P1 p! m   inspect number% d, M6 q, ~7 f1 N1 R0 c1 T. h
       when 1 then $ I" s# ^4 z4 u# }* X3 R+ E- K6 l0 j
          print "not a prime number": M# n/ n& M* f" p0 ~
       when 2,5,7,3 then
4 u& \* y8 \/ `) x5 G: n          print "prime number"( b. |( a  R$ f4 {
       when 9,4 then
: p5 E6 _  h4 @          print "square number"
5 O1 b/ v$ m; b2 D4 e       else
7 c7 q( I3 [+ W  o: Y' |* p: w          print "no special number";; n  o6 Y- G% R0 e% U6 @1 Q4 _
          print "or number greater than 9";7 i0 E/ A0 {0 Q. p1 E/ v. }# x, `1 U
   end;
) S4 g1 B* v& l; |: n( }/ g, |! j' E5 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, 2025-12-30 02:09 , Processed in 0.014269 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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