设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9221|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is) z' W- [( J* m9 m9 e9 L" i) _) Q/ J- C
       Ci :integer; qi : integer
4 V6 N" Z# B( S1 I0 ~4 ]do # i; G/ @* E' P7 e( V1 C4 U+ L( ^
       inspect Ci
5 Z1 X- r$ f6 B) M! A1 m' s" y. _$ Gwhen Ci>0 and Ci <=150 then
/ |1 P) q: \  j; l1 ~       print qi=1;- q8 _4 Y9 c" Z9 F0 |0 |1 J
when Ci>151 and Ci<=500 then- u) ~' D5 D4 G3 I6 b* c
       print qi=2;. r8 Z( w& p) h; T. _
when Ci>501 and Ci<=700 then
7 R5 M' K# m) m       print qi=3;
% S1 K$ Y, S1 b1 ?2 q/ t: Awhen Ci>701 and Ci<=1000 then1 `/ w( D$ W; b, ]  d! c
       print qi=4;% p3 g$ I, M- a* O/ n  ]
when Ci>1001 and Ci<=2000 then5 Y" _0 X2 l1 ~, k8 O% `4 G4 {
       print qi=5;
3 T% Y: j4 s2 ewhen Ci>2000 then
, l( Q, M5 Z* d& o! R3 _       print qi=6' a" Q4 S, F, Z% \$ |
end;7 Z- z, t- j) T, ], x7 O& ~5 Z
end;
" w  f+ a2 T$ ~2 n" l) ^
5 L2 C; `' [/ ]5 d          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?* d, o3 Q! h) m9 W; F7 {
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:  s1 w# ^- w2 `$ i
(number : integer)5 [  d9 K5 x. o; [7 }; n0 A% c; B% N
is
2 b$ U% z" E* L* Udo
' A+ I3 u0 P1 _7 p2 N   inspect number
9 o( ~6 j# z$ h6 Y: S       when 1 then
' T$ L1 t+ b0 E8 g          print "not a prime number"* V, ~# V2 T0 R: d
       when 2,5,7,3 then
, ~2 d& f$ w* O5 u6 B5 b          print "prime number"' O/ O  G2 q7 E$ I* o5 X
       when 9,4 then / Q5 w. |7 t( a5 j# J' @$ V
          print "square number"* u# I6 [* c" S6 B- F$ u
       else
7 i) s0 ^9 Y4 r3 m8 b          print "no special number";
" }& `7 J7 j$ |          print "or number greater than 9";
: I5 M8 @% }% e' e% M   end;
6 K* Z7 V& c# W1 Z; x! y8 w7 Vend;
 楼主| 发表于 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-13 09:04 , Processed in 0.073836 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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