设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8919|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
5 b  @( R/ l: F       Ci :integer; qi : integer
6 e6 V1 U' \  b9 e$ C' t( Kdo & e& \! y9 [, f! i
       inspect Ci6 T7 f& G4 w* ^9 b# k1 j
when Ci>0 and Ci <=150 then
. r$ o1 P# h% }, o; r! Q$ F* E       print qi=1;% S- h; @# `! k4 [5 U
when Ci>151 and Ci<=500 then- _+ X# J1 G- ]0 W8 b! W7 ^& Y
       print qi=2;% `; @- P5 Y1 E( U3 u
when Ci>501 and Ci<=700 then8 m. Y% r$ e, L  m1 h- g
       print qi=3;
: L6 Z& d" u+ F: K+ j8 Y0 Vwhen Ci>701 and Ci<=1000 then) N5 r, h8 h$ k/ ]
       print qi=4;
5 c. }6 \7 G& Ewhen Ci>1001 and Ci<=2000 then( l  ~" u0 t: n
       print qi=5;, E! j) U2 K. W3 t+ K) N
when Ci>2000 then3 o! f( e/ A9 q0 p0 w0 t8 J
       print qi=6
7 o( F- f/ G2 t1 j7 n' \, s! [end;; r; f  z# T& R% x2 s0 W
end;
1 }6 z% C, F8 g  e- \% B: E3 Y  C; C
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?1 L9 ~. v6 j- Q/ s, o
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
8 X! Y) b, X4 X# ?(number : integer)
$ z# ^# d( E2 Q4 g. ois* w3 t. J& M! i: ]7 m7 {
do
% R1 {* d& E7 ]/ q   inspect number: S8 ^. W) ?* e
       when 1 then ) n2 A! C1 J+ E* r2 j) W  I% e( d
          print "not a prime number", w9 g% a' V$ z8 w
       when 2,5,7,3 then 6 }1 V9 a) T2 q( n! l
          print "prime number"" T3 s! d2 X* Q$ v1 b  u2 x6 D
       when 9,4 then
: G( D! D3 o9 Y8 H          print "square number"$ o2 i6 m9 V2 g; L3 ?* N* F
       else
+ ~) ^: c9 V* ]1 h1 w% P# d. ~          print "no special number";
9 N' h; \3 j) A5 p7 q! Y          print "or number greater than 9";
. h0 @( B; p  q0 z) w& e& s   end;* L1 R' a$ t2 F; `% b0 b6 G* d
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-7-16 07:17 , Processed in 0.012140 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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