设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9235|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
3 d5 T' x, U7 M  x$ l8 r       Ci :integer; qi : integer
# |) C$ ?4 c% g! A6 Xdo
9 K2 l3 q% C$ h       inspect Ci
7 x+ `: R2 g+ K1 u9 M5 k: @when Ci>0 and Ci <=150 then 6 o- ]; |8 h" Z2 P
       print qi=1;
+ z- E4 O9 F9 P" F4 |) R. Awhen Ci>151 and Ci<=500 then
% e% e- B/ ~1 \7 w2 r; o! x       print qi=2;
  U3 b+ q+ t4 \' ]! R, Y! Z) ^when Ci>501 and Ci<=700 then  m& h' f8 I) @* G4 q
       print qi=3;1 E9 z, q2 [) y6 v+ @! L
when Ci>701 and Ci<=1000 then
& ~( o$ V. \* V       print qi=4;3 I! o; W4 e& L1 i$ W/ [
when Ci>1001 and Ci<=2000 then6 W/ r7 C1 S7 \6 e. P# l" Y' }8 w
       print qi=5;- r0 A; s7 f. s2 w9 u: R, p
when Ci>2000 then3 j8 d; B/ H1 E1 o1 T, W
       print qi=61 g/ o8 S0 M* l1 |) |; l$ h
end;
; U; l+ G& Q# ^2 ^) j0 Qend;1 j& o% @3 G: }3 l; g
# Y: `4 T' c- K
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
+ t' [2 E; b; n* S  ~" j4 f          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
4 s3 H+ S1 z1 f  x(number : integer)$ k* b: ]! y- _8 k
is0 E9 E1 `# Z$ [; n" T% d4 [
do
: p) ^7 I0 i2 {* p) ^   inspect number* e- b- \% t; \9 }7 I
       when 1 then
4 Z6 M2 L+ `) G& W' L; T  q# `          print "not a prime number"
; x2 |3 \: V/ v- m1 |2 [       when 2,5,7,3 then
/ I: l# u) o% F, o7 A6 k0 l4 C          print "prime number"8 k. `; E) T/ @" q" P$ A
       when 9,4 then " K: p% h$ m! C
          print "square number"+ D* V6 J" ^" m- S7 i4 Q
       else8 v( d6 o5 G' Y- _/ a2 z% m( S
          print "no special number";
+ k/ L& o2 h$ `6 V          print "or number greater than 9";
! V- m& \- e+ I/ k( }   end;' ?4 y) g# ?% U
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-8-16 08:37 , Processed in 0.013087 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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