设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7408|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
  k( D$ G  G3 l4 `2 b       Ci :integer; qi : integer4 R1 J7 E- E7 X& f* f* }. z. a
do
! o8 j! E' _* x: b" }9 r2 h' X       inspect Ci% H/ {6 I: @- E
when Ci>0 and Ci <=150 then # m2 ^) R$ \7 C4 x/ [" [# B0 F7 x
       print qi=1;
# q8 R" G4 T" f$ P+ xwhen Ci>151 and Ci<=500 then
! A2 E3 W3 S" Z0 p7 }+ A       print qi=2;" @5 j$ p% w3 w8 r0 x
when Ci>501 and Ci<=700 then
- y$ T9 I! l3 |( e       print qi=3;/ _; M/ B& a. [& N( X( E
when Ci>701 and Ci<=1000 then# d, c: t8 L& C" f$ O
       print qi=4;; I8 R$ W) r. h5 \; F. S4 j/ X
when Ci>1001 and Ci<=2000 then
' t$ r- p- E8 Q8 y9 c! i- n       print qi=5;5 ?% B6 Y7 z1 p5 ~
when Ci>2000 then
" m( P, [$ ?/ @' g, d! N       print qi=6
( ?0 e8 Z: I, u; h" @1 w! dend;- l0 ]" Z& S# B( a4 R
end;: p" z; [. `; ~: L4 j/ h# ]
9 ]# L' L8 \  b6 J( l* {
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?  I6 H- N* j6 k' }' M: K( _0 B0 H
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:1 L8 B& F! F2 p
(number : integer)( F' A9 X4 _! r; d  I
is$ g( Z, z" }0 \, D6 V" G
do$ A, R, e$ \# k
   inspect number" h/ x9 w2 K5 Z/ i8 v
       when 1 then
' v6 q) E5 Y2 a+ C) H- y          print "not a prime number"' u# ^! k/ I7 S8 b; M6 E
       when 2,5,7,3 then
; l' @- Q! f/ p7 b          print "prime number"+ S8 M) G  ~( @& _( i3 M
       when 9,4 then - E$ l' b* v% R4 W
          print "square number", A, M( P9 I; c( o
       else) B, J3 y( T' B$ P$ h, O+ m
          print "no special number";
7 Q- b" `% D$ N8 {          print "or number greater than 9";
- E" S; N' C" c* f/ c, b   end;
  [9 e2 r1 v% ?1 X/ Mend;
 楼主| 发表于 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-11-18 20:47 , Processed in 0.018175 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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