设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7978|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is9 d+ M5 G  K$ V7 ~+ ?. W/ O
       Ci :integer; qi : integer
: V- J; f7 ]1 _do 7 n3 ]) ?5 _% `$ a( ^( `
       inspect Ci
/ B- {1 g1 g9 j1 L9 t3 Jwhen Ci>0 and Ci <=150 then
2 E3 u" G% D1 A" @       print qi=1;( A$ B4 D) B5 L1 A- G
when Ci>151 and Ci<=500 then( J0 ?, t# C* S$ l; b
       print qi=2;% V$ s; b3 e$ Z) q1 E/ b, u
when Ci>501 and Ci<=700 then
7 W1 C2 |0 I# ?) R# J. f: B9 Z       print qi=3;4 n5 j2 Q; U$ y2 A. n
when Ci>701 and Ci<=1000 then+ \6 _" r/ ]1 y& O8 @
       print qi=4;& M/ g6 W& o  B, b2 F: b
when Ci>1001 and Ci<=2000 then
4 \# @' a; e4 s1 q" z  Z4 H9 x7 M       print qi=5;6 E" y. |9 x* P4 I4 O
when Ci>2000 then
4 |5 c/ ~( D+ N. w, ?       print qi=6
0 q" F3 O3 n" \7 ~7 R! V! Fend;
* p) Y# e: c$ j9 `end;+ @+ b: C0 i' s( h* q7 A
. j* F+ U9 G; L0 D3 G
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?9 i  q/ t+ J6 a
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
0 I, o8 |5 z1 W  u8 n" h$ \* \$ i1 l6 H(number : integer)
( A: U/ Y2 A, a" ]  his4 E: B8 g! C8 L% X" I& `3 A. {  j
do2 F# I# f' {  v# I( i) R
   inspect number
* r$ s, e0 K2 }& T       when 1 then - v( I2 a/ D6 x- f+ V8 E1 E
          print "not a prime number"
+ h2 c. k/ s& A       when 2,5,7,3 then 4 \  K6 q1 b' ^
          print "prime number": p5 S5 Y7 ]+ @# B. N
       when 9,4 then
- x# j( y9 X3 U* x1 t          print "square number"$ l- A+ D6 u3 R, E1 `) d
       else1 q+ L' {# i2 O' k. A9 Q' p& T
          print "no special number";
: t+ ~" A( ~2 N# V* b  v7 z+ U- \& u          print "or number greater than 9";2 D6 r- J$ b6 Q
   end;% t* z9 r7 U2 n" [: M) W( N4 V
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-2-24 21:07 , Processed in 0.013477 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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