设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8579|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
& q9 |6 X3 `: b7 a       Ci :integer; qi : integer
; H' J9 Q9 S, }  W" X0 Bdo
! j6 d( @5 V6 A6 l$ g       inspect Ci
& D1 ?' O  K4 p1 ewhen Ci>0 and Ci <=150 then
! s+ b  y/ ?  e6 s, V       print qi=1;
( r- N% `% Y, t. d  B. t; `when Ci>151 and Ci<=500 then
, R2 K1 B' L: N" T' X, W$ ?       print qi=2;
8 W% @9 Y# s  ^: ^5 x& q8 s3 iwhen Ci>501 and Ci<=700 then
( [8 p) g  V% B+ l0 j( o1 P       print qi=3;
- ?* I. Y) W- F% }' R. Ywhen Ci>701 and Ci<=1000 then* q: H( [# O! B/ V, {5 C
       print qi=4;
4 j3 `- q! M9 X% z( c* Kwhen Ci>1001 and Ci<=2000 then+ _. I# p) ~) q, F" D
       print qi=5;
# U1 H' }. t' Iwhen Ci>2000 then$ E+ c9 z' T2 f) S, r9 a- b1 M
       print qi=6
* C- C5 Y0 T. }6 O% X* y  cend;5 ^4 Y  f8 j+ d. O# }0 C
end;  S/ O% R! k: h( ^
: ^- F. d, ], Q& ~* d; z0 }
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?+ D/ J5 N  V  i) l
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
; E# ?) W: H( {(number : integer)3 }" f- F& |4 Y8 y# ]$ G
is4 J/ Y- y% C( d% c/ {$ V9 n3 [7 N/ r
do
- s7 |4 {( a# L5 T3 J. x3 \   inspect number2 U% x  h) S9 O0 y  z4 C
       when 1 then ! G- d+ Z/ \( ~  J9 z; _
          print "not a prime number"1 z& R5 O; v( H0 p% W7 E! t
       when 2,5,7,3 then ; i" V" L3 C0 M1 r3 S( f$ ^
          print "prime number"% M7 c/ Y+ K7 N0 |% z) c! K. r
       when 9,4 then / U: p  ?0 \8 A1 {
          print "square number"
. Q1 W1 t7 ?5 y+ ^% P       else
  _3 @- t7 T" O* g: Z          print "no special number";
; d, y6 P- j$ n          print "or number greater than 9";: b/ D9 Z0 r' y
   end;
- a! E5 K1 u. b2 K) u; z7 F. M* R0 Gend;
 楼主| 发表于 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-5-12 19:17 , Processed in 0.016443 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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