设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8313|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
; Z/ M$ S5 J: I: M- c6 }" o       Ci :integer; qi : integer0 v* g1 t$ G# c" A( V! m1 @
do
2 W7 x( H7 c6 \% P* |& Q  Z1 x       inspect Ci
' ^  ^9 n- K2 H5 `when Ci>0 and Ci <=150 then
1 @) }9 F1 I! c2 z/ W9 x0 J. @# T       print qi=1;
9 O1 i) w/ f, cwhen Ci>151 and Ci<=500 then3 i/ i" X! Q2 }( [) S- C, }
       print qi=2;
0 T' p, K. u5 F: u' s' O6 |when Ci>501 and Ci<=700 then3 t) b1 t( q* Y& ^2 P# Y' b
       print qi=3;$ g0 ^/ |  @/ a/ N
when Ci>701 and Ci<=1000 then1 U& ?  ~' }. S
       print qi=4;! N6 D; x* h8 S, i" q0 {8 O+ A
when Ci>1001 and Ci<=2000 then
. x! M8 t% W+ b5 A3 n       print qi=5;& L' N0 e$ q/ g& H# |7 ~
when Ci>2000 then
; X$ ]% e5 f' U5 A7 e; \       print qi=6
4 k5 j* M5 K7 r, l) T. c/ J- Q% Vend;
( o# R/ n  L: V. |7 \end;* N" Q' L0 U( b7 d. ~" ]
5 Z9 H) ~0 F9 _8 Q2 U1 [: g  p
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
; r- g6 M" p! I3 [: Z+ L          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
1 t! ?. k6 g: j, P/ R* a& L(number : integer)
& ?/ R; Z1 @- m1 zis
% S. H, q1 p" c  ?: ado( x+ l8 m0 ]) I* D% g( L5 j2 @
   inspect number8 `" t: w  n# H$ N/ ^* A
       when 1 then $ y  z& f) C% i& d
          print "not a prime number"+ M8 k/ `, h3 E' Q2 n4 }. c
       when 2,5,7,3 then * S" w1 g' O+ Y7 ^! l
          print "prime number"" Q1 F  n3 V* R' L, D0 c
       when 9,4 then
1 x0 X& x1 r" S" m. b4 |' _: p          print "square number"2 Y) h! g, m$ ?" r  ^- y- y
       else
6 n6 |# E' @6 B4 w: i          print "no special number";6 W' ^2 X+ ]+ o& O/ F5 }+ G: \7 h
          print "or number greater than 9";5 F, `, N# P, b. X1 N
   end;
7 S* ^  U" z: `+ \8 Jend;
 楼主| 发表于 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-4-16 13:16 , Processed in 0.016837 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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