设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6489|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is# m& A% O$ T# T0 y$ n9 v
       Ci :integer; qi : integer
* `3 a/ e) i( ndo
0 I$ O" U$ I  W' {2 c       inspect Ci0 N, I) v% T# |+ J2 i- P. j
when Ci>0 and Ci <=150 then 4 Y* K0 `9 g9 g8 O2 L
       print qi=1;6 @/ o3 P$ O  A, q* o  I. d
when Ci>151 and Ci<=500 then+ K0 Y- z9 x0 D1 `
       print qi=2;6 v6 P+ I$ K, c/ W0 Z
when Ci>501 and Ci<=700 then; Y" G, v  `) }. V! q, j# A2 U
       print qi=3;
# o6 Q! Q5 s  t2 ]when Ci>701 and Ci<=1000 then5 t( r( s& k! L( J0 l# y
       print qi=4;
! G, i2 _( X( F9 [1 ?+ k! Uwhen Ci>1001 and Ci<=2000 then9 G0 K( Q2 _8 m5 v
       print qi=5;
/ q6 e3 J3 g% m+ `0 k) p3 Cwhen Ci>2000 then
7 P  a$ {8 x+ |0 C: }       print qi=64 Z+ Z9 X9 q1 J2 @% O4 p0 }" n% S6 j
end;8 X+ O* \& C, {- P- D% y
end;
8 a/ ^( M. Y. u6 Z: C$ A5 T+ P. D6 M0 V& |: E+ f" }0 ^8 x
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?2 q# p3 M' m% C: }) \$ h
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
/ I2 ]+ U, ]1 V6 D5 d( ?  V: z(number : integer)
& P# a8 W, X$ d- W4 gis7 }5 R% f7 |& h7 p% _0 P
do
2 D$ e: c9 s' c1 h7 c. c   inspect number  H" D; X% b; g( z: ]2 A$ B1 e0 e
       when 1 then
+ U/ s+ m  A3 f          print "not a prime number"
9 k& x- `4 }3 a; r( W5 m       when 2,5,7,3 then " I& q: [; W/ |4 o; R6 c
          print "prime number"7 M# L4 s/ J; d$ @# X
       when 9,4 then
! ~1 \2 U+ J. k: D          print "square number"
0 _# h0 t2 U3 L7 A, f/ f- Z  N4 o       else$ Y1 O  b3 E( r9 i) V4 S- @3 p
          print "no special number";
8 R# J- N5 c2 K          print "or number greater than 9";
. |$ s: l1 ^$ f( B1 D, ^   end;
/ s* E, A; X2 P& m3 M3 P2 aend;
 楼主| 发表于 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-7-3 22:55 , Processed in 0.017678 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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