设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6974|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
; @! U  L4 H! N# r% I: O1 ?' _       Ci :integer; qi : integer
3 M* n0 _) I( u) Wdo . D- C. J! D2 p6 M+ u8 Y" W
       inspect Ci3 f+ B0 d! P0 U. o1 C+ k& U. p
when Ci>0 and Ci <=150 then
% F% ^. q' H" {" `) |4 @" N/ R       print qi=1;
1 j2 u9 n/ W) h9 l( n3 rwhen Ci>151 and Ci<=500 then4 ~* M$ u- T0 q2 n/ Q2 l9 R
       print qi=2;
3 H& r4 o3 n1 N1 H8 l$ _when Ci>501 and Ci<=700 then
& z8 b2 J  b6 K       print qi=3;
' D+ f: P0 X* m+ ?3 A/ `when Ci>701 and Ci<=1000 then
( e! {0 A" O; |4 p       print qi=4;& ?+ ]2 k3 `5 b' e
when Ci>1001 and Ci<=2000 then
& N6 P8 {3 {( C+ L1 i0 ^       print qi=5;; U" e3 o: o) @9 G
when Ci>2000 then
- ^* X. k8 ^' P: j" i1 u       print qi=6
0 s* {  G( ?1 c( nend;  [* Q  q& p; L- T( H1 N
end;
8 D% d: f9 K- |& u3 y; l$ m- g$ Y; h( X6 G4 Z! r; W# s! L
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
& a5 L8 {9 U& E# j          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
" }* P" E& M, X( Q(number : integer), Z: W' H0 W, g2 p6 m7 [
is: `4 P. H1 i4 L5 L  G
do5 P3 T  X' H' \/ x& Z+ [( c
   inspect number$ M! f/ U" g2 d) V* m" q8 J
       when 1 then
. |; ~8 d1 p0 Y/ L0 q) q, h3 H          print "not a prime number"" ^& E& S1 t9 c9 ]4 S9 E
       when 2,5,7,3 then # ~( [% x: p' l: y8 T) C5 u* N
          print "prime number"
! Q" S7 Z" l2 N* \       when 9,4 then : [9 N# l; E4 s1 ^
          print "square number"( K. x" @4 r. T0 W
       else! J! K* r/ Z/ e9 f! m5 V  Q
          print "no special number";
# B8 l3 t) w5 L6 f3 M          print "or number greater than 9";3 T# w+ _# M, B- k5 C5 M
   end;- ]2 g6 K7 s  D+ E  A! 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, 2025-9-18 21:53 , Processed in 0.014649 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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