设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8891|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
! P6 h3 d" b* N* \       Ci :integer; qi : integer
" o- \  @8 s$ o' wdo ) s" H6 j5 @  x8 ~4 @  P
       inspect Ci' q" g: S7 e5 U! h& X/ w7 f
when Ci>0 and Ci <=150 then
5 c& P& ^# w( I/ O* c       print qi=1;
0 R7 z7 S& }3 m/ t0 s/ k1 K  jwhen Ci>151 and Ci<=500 then, K3 ^1 C  D5 k# `  C5 f
       print qi=2;
- R- |2 X# E% E% }8 U9 H$ H5 X& W) g4 owhen Ci>501 and Ci<=700 then
# n! C( W4 L% l) W$ j       print qi=3;! h  _& x7 ?4 E
when Ci>701 and Ci<=1000 then
: s3 g& C$ z: O# M5 F' K; n7 m5 d  u       print qi=4;
, q$ W3 P0 M( P* Qwhen Ci>1001 and Ci<=2000 then
4 a9 F! W. v; K0 t9 ~1 e       print qi=5;3 H' |# w5 ~# j
when Ci>2000 then, L% y, z: Q. i
       print qi=6
- p/ _2 b5 S, R0 R9 n0 Xend;# k5 y- B3 s5 o# X: u
end;
1 s+ y7 C$ ?8 h; J" h! Y# V& ?/ C& D) c  J
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?* \" e2 J) C3 ?/ t; k6 @
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:4 A' e: |# z5 J" X# t2 Y: N
(number : integer)
# ~7 ^! D  }+ m$ `9 B1 f4 iis* ^  y! Q" e* y! r( r
do0 O5 p9 t6 q7 k4 W9 Q- t7 {, F
   inspect number; P  v; v( s$ T/ l
       when 1 then / ~9 a, q8 J9 F8 L9 X
          print "not a prime number"9 f: n$ L) A( R7 l' n  T# o
       when 2,5,7,3 then
9 @. ^( ]) V2 K, o          print "prime number"
6 K  E: {* j8 l( [       when 9,4 then 8 H1 Y0 L- E/ B/ g% f+ B) @
          print "square number", E! I' x: l* J5 ]) W
       else0 S2 ^. c9 i# b- R1 }6 ~0 W' ~" H+ z
          print "no special number";
6 f% `4 m0 R" Z# e& f& q          print "or number greater than 9";% a( M1 j& q5 X
   end;
6 n" q8 R6 `9 x, E( yend;
 楼主| 发表于 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-7-14 14:26 , Processed in 0.012263 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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