设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7526|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
  a- e. m; D4 L% A4 I       Ci :integer; qi : integer* I, c! e) [2 K1 l" |- r
do , ^$ W8 I1 U/ [
       inspect Ci" r  i7 x; x4 y9 l) P9 X) D- R) J8 L
when Ci>0 and Ci <=150 then
( k* H1 k' O1 X0 m, z% Z+ t$ \       print qi=1;& z! y! G; a3 U: R8 k& X
when Ci>151 and Ci<=500 then
1 [. n8 E; G! Q# F- S& |       print qi=2;! e( ?5 e. ~6 D. G
when Ci>501 and Ci<=700 then
# o. ?. g. |$ p. L; `       print qi=3;
0 x5 f& R8 K  j2 N8 Iwhen Ci>701 and Ci<=1000 then
/ I# Z" z+ Y1 p& _; G* M, }       print qi=4;
4 ~. i$ x3 B2 g+ d. ]1 `when Ci>1001 and Ci<=2000 then
; k& w, r2 Y& W) ?       print qi=5;
; \* e0 I) y& o# f! w  Jwhen Ci>2000 then
1 |- d$ ^! D: x, j; w. S& }; D       print qi=6
0 V+ F5 u. V: c7 N- |( Fend;0 s# S0 d% q/ X" `- j0 @
end;; \1 U' g7 Z" k0 D' X" {
; {4 l+ V4 C, K; i0 r, s* t
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
& U& G6 ?0 Y8 T+ V: w: N+ v& a          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:, Q8 q6 c1 N$ \6 s& q. u) E
(number : integer)4 A' t' n' z/ h$ H0 b
is. d  L0 m) B6 J4 D3 g7 G+ d
do% u8 |, c' D; o; b
   inspect number
( h+ Q% S/ X, l  I: N       when 1 then 3 E& w7 @# s  O) m. z
          print "not a prime number", q& d2 v$ L# R$ {# o! Z4 c: S
       when 2,5,7,3 then
6 X0 c. t4 j. s7 ^2 }. n; p          print "prime number"
" Q) I* h+ G: S5 J( k; Z8 b2 G       when 9,4 then
( u" n6 \  k$ V' r          print "square number"7 j$ Z; E( p& `8 f1 e
       else1 x: h; D- P0 Z: ~0 L
          print "no special number";
$ _* i( i% x; h3 y' f9 J          print "or number greater than 9";
  W2 n' T0 U3 i" w8 i* j8 h   end;; I& f  A( i% N1 Y" e+ l1 ~
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 15:29 , Processed in 0.014279 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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