设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7522|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is. n( L, O9 y# R* l, s
       Ci :integer; qi : integer1 l+ f  B* V8 h5 \3 H1 e& G
do
, w8 [# k* I" U/ }       inspect Ci
7 b* l7 p6 t4 H, rwhen Ci>0 and Ci <=150 then
7 j5 h$ r% _& X2 r, g       print qi=1;. c& @. b4 O. Y! O1 R
when Ci>151 and Ci<=500 then6 @3 O4 b" l3 w0 j
       print qi=2;: T5 {) [2 N) v; x- X1 c- E7 P/ |
when Ci>501 and Ci<=700 then8 X) l0 G9 Y2 Y1 {: u. V
       print qi=3;3 L6 P. C( Z) }% w2 K
when Ci>701 and Ci<=1000 then
4 P4 M1 a) n( R. g$ O  c4 ^% u- m       print qi=4;4 M1 I: C! V! n  ^1 B1 Z# c/ B" C
when Ci>1001 and Ci<=2000 then
8 V  _) R) U9 Y+ e6 I5 `' K       print qi=5;( f( g) m5 t9 l7 K3 Z
when Ci>2000 then* A8 J/ u! {, q+ y$ {6 F. o
       print qi=6
6 [: V$ m0 u: z7 n6 ]2 O" b: d9 Oend;* x6 U: F+ y: r3 R$ Z; A+ e+ B0 ]
end;
/ n: g% z$ P* V- v$ R7 Y
6 D3 w4 O6 G/ _1 z% D          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?% `# z& s8 t7 [4 ^
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:( ~4 C. [* {$ \" `1 \7 ~# p
(number : integer), m' z2 T3 m/ K/ k$ Y, O
is( }. T  f" C5 ]2 L6 H
do. W6 l7 j" a& D7 ^; T, N' J" q
   inspect number' r+ ?+ J) ?. d3 U; m
       when 1 then
7 z& K* O  M" }# |" o: B          print "not a prime number"; A5 Q# u$ o7 L9 h( d
       when 2,5,7,3 then # @% \% X" p. m+ S8 q
          print "prime number", f% J& J9 r2 e  o3 p, D( A  W
       when 9,4 then 1 x/ J6 }  O: G$ x( z
          print "square number"
9 I. @2 n3 a4 H& C1 w- K       else
) `: q, g0 b, Q/ Z          print "no special number";6 q% B1 J7 x3 _) n
          print "or number greater than 9";- X* d: Y0 Q5 \7 Z% H
   end;2 f! D3 H3 z, @7 e5 U) h5 Z
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-8 03:57 , Processed in 0.012952 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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