设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8016|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is3 F3 {" c; l4 t0 \/ q' `
       Ci :integer; qi : integer
8 k% B3 {. y# Z; o8 L% i: {/ Edo
* x* N' m& I/ O+ v$ i       inspect Ci
% I- M- F$ g! w) l! |when Ci>0 and Ci <=150 then
, _- I! d# o" `. c; o$ O* b; G       print qi=1;
8 h4 e! c: x; [/ ^9 Z! l" T- Jwhen Ci>151 and Ci<=500 then8 M8 }0 [% B, L9 `7 U3 e# r
       print qi=2;
: f. x& a' |* U5 {- @5 H) Ewhen Ci>501 and Ci<=700 then/ g( q& q/ n0 z& \! e+ ]( V% z
       print qi=3;
5 g  `  I" ?! Q) e) R; twhen Ci>701 and Ci<=1000 then6 N$ w! [9 u5 r! H7 |, O0 ?
       print qi=4;
" `# Z4 `1 P( H  Vwhen Ci>1001 and Ci<=2000 then$ }4 a% }) e/ X' A
       print qi=5;1 R! }) D- x5 x4 c5 @
when Ci>2000 then
/ s6 X0 X# J* r2 I( X3 w9 c       print qi=6  T% U3 W, ~5 P1 u0 d) ?. x  P, D3 d  G
end;
: f( F/ _8 \$ B% C8 Q$ E6 oend;3 }7 T/ I3 k4 o- S& l' u2 ^) B  M
) D/ W- y' R3 r  ~; M
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
; ~) @9 p: p/ W' e, ?: J1 C  @          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
6 Z) y9 T# l. |$ `% t6 Q* f(number : integer)* n0 d- c: y: ^9 \1 y$ w; X8 S! b& o
is
; X4 V' L  U$ s" qdo
4 [- _+ y8 K* k" X( V. M   inspect number
0 Y. G* z8 z. j( z       when 1 then ; b- d/ u. ^4 J8 Z1 C& b
          print "not a prime number"
6 s! b4 s! \3 _7 J: }       when 2,5,7,3 then ) U( x& P% h2 G- p9 @. z2 `, n7 p
          print "prime number"
) y2 [% |: ~% |2 u) Z( T: r       when 9,4 then
: q8 ~: q0 C9 G& W0 H' Y          print "square number"
5 x/ a* M5 S7 f. l2 t- J% X       else# l) R- }; a, P7 X$ u
          print "no special number";; [  q8 i& x; }8 S
          print "or number greater than 9";
: o' m* ~% d5 n   end;
# U6 |6 T) s. z3 ]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-3-3 21:39 , Processed in 0.018776 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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