设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7554|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
/ {+ o3 ^) Q. g$ ^5 |       Ci :integer; qi : integer5 U/ t% X; u9 K2 D7 f" m6 m
do
: C! [5 d, D' O) z8 t       inspect Ci
5 R# G+ S* {8 b# l+ f' Z0 ?! _when Ci>0 and Ci <=150 then 0 T$ u; F4 a, c0 a
       print qi=1;9 {' q/ K+ D" n
when Ci>151 and Ci<=500 then
" ~8 c; k+ o/ w# c8 |       print qi=2;" N6 F& n& E2 R2 v
when Ci>501 and Ci<=700 then
: e) }, k3 h) F# }  ~5 M( g! x; {+ C6 s       print qi=3;( M$ R8 a3 M1 G4 b; M% V6 ?/ p/ J
when Ci>701 and Ci<=1000 then
: g1 |: t( C3 w2 @6 j& H% K       print qi=4;9 ^, r6 }3 s. a: W& o
when Ci>1001 and Ci<=2000 then
- |% u* l) O. c' r8 T3 t       print qi=5;* |1 ]  n2 X0 }* i1 d( u$ ~
when Ci>2000 then
3 |" x( M  y  T0 N8 z3 x' d4 n$ |       print qi=6$ p+ w6 {1 p  z4 g3 D
end;
% \- u: Z& {& Y) o0 _2 }end;
& d6 H6 D; e# W) j9 V
2 X( u% t. D& K' W, j  [          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?( F$ i( k! l$ A3 C: T
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
) P- R" M) c/ y1 H& `; R3 {  N$ W0 |(number : integer)
4 K: i6 X6 o2 n! s7 R- _( Gis8 B/ w5 x  T; L
do# U9 C( E" H% M8 w) C
   inspect number7 l* `8 R, B- V8 H% x
       when 1 then
- z( w, ~* ~# K$ ?* ?          print "not a prime number"
3 N$ f. G; {' f+ E. z+ ^# e, E       when 2,5,7,3 then
; X$ p8 B5 r3 N          print "prime number"$ M+ D* P2 p- p0 K- \
       when 9,4 then
& ^$ Q. R' |. J$ w. B; c3 c          print "square number"
2 G5 S# ~  Y. v  Q4 l" F       else
* E( c3 L% }# T0 o" A/ J2 p          print "no special number";
, t0 m/ A/ u' J2 @3 r& Y          print "or number greater than 9";
' a+ y& v! m6 S   end;
, M, Y1 J& [- r' Q! m$ |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, 2025-12-14 02:12 , Processed in 0.013427 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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