设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8886|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is# `  j- Z3 j: [" a# h# f
       Ci :integer; qi : integer* u2 ~: }/ p, ?" N  s- `9 Q8 G
do ! ?# a3 v0 C7 B8 a4 g
       inspect Ci6 a. u- J+ b' T; C+ i
when Ci>0 and Ci <=150 then 6 ?' Y. C$ D) D! Y3 G, Q
       print qi=1;
& g: S5 O: q# x5 e: f! owhen Ci>151 and Ci<=500 then( A7 ^) T& d& s
       print qi=2;5 K) @( l4 J7 n; T* _3 G
when Ci>501 and Ci<=700 then! F* z5 F$ K$ k, Y$ i: w
       print qi=3;% H+ ^) ]( s! ^; ]3 k' e
when Ci>701 and Ci<=1000 then7 Z1 R) O6 {4 E
       print qi=4;
" x6 B% |2 [  l5 Owhen Ci>1001 and Ci<=2000 then
2 ?' g* X, Q* G* P0 C9 d' k       print qi=5;: h! c) \) y) b
when Ci>2000 then
0 ^9 s9 P. v9 c9 P7 Y  }       print qi=6
4 V6 X& g9 N" ]" mend;8 @( l: ?! r3 @
end;
' D) b# N+ r/ I& q- G0 u, Z; e# n) E
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?' |, x4 c+ B. D4 `, M$ z
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
) O3 U2 M1 ^1 g: A5 J(number : integer)
: o; d5 }( i  N1 k& @$ @4 S- his
6 W- P4 e9 W! Ndo
: p, |- E. V  @) @: D4 f   inspect number. W& d# i0 ~' C' S! T* ^4 x
       when 1 then 5 |$ G6 K9 F0 q5 X; }
          print "not a prime number"
, z, S" i, s% {1 w# _, C9 C( C       when 2,5,7,3 then ; c. A% E9 A* G, q  I9 {6 E! N; K  g
          print "prime number"2 N$ _" J9 F" t) q% G0 V0 ~& K( q, g
       when 9,4 then
0 D: L8 q2 h% |          print "square number"
% T+ ^9 E4 T: k6 c4 [; e       else9 q: T2 e/ k& M! b; G
          print "no special number";: A; m0 b$ b7 w  }
          print "or number greater than 9";* m3 r8 n& r" \! }5 J+ v
   end;0 a2 r$ f! g' `) X' p* k' U% p- y3 O
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-7-13 11:33 , Processed in 0.018545 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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