设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6961|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is# B! h3 V" O* D3 s% W
       Ci :integer; qi : integer5 g- G& g: H) _/ h% d( e4 U# {& F
do
0 H9 e7 Y5 _) u- n3 E       inspect Ci
/ O9 s+ W8 J6 Y- K, bwhen Ci>0 and Ci <=150 then
; ?* M9 k8 P/ N% I7 _: C       print qi=1;
2 v; H6 a* A& R' e- bwhen Ci>151 and Ci<=500 then5 H) ^5 g7 C# f8 i
       print qi=2;
9 }! ]# u, v0 M3 O7 |when Ci>501 and Ci<=700 then- G2 Q$ ^; W) [! w+ a2 }, |
       print qi=3;+ Y) j; l/ ?" D! J# K6 @
when Ci>701 and Ci<=1000 then/ {3 |# |8 V* |( b$ e$ q$ ]
       print qi=4;
% l- j2 ]2 c+ k/ Awhen Ci>1001 and Ci<=2000 then2 m8 G7 n, A- `+ \0 a
       print qi=5;
% Z9 d( N% Y: {- f/ a' ]; bwhen Ci>2000 then2 Z; w: b- f& S9 Z$ m2 a- [
       print qi=6
* T! y8 x& k: d) z, \end;
# @% c, f  J3 _$ u# Eend;* e- f) b) U1 }6 Z3 X6 D4 i
+ M% L) q+ I- A
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?$ j! }4 e: m9 q3 b. _2 i2 b8 \
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
$ T6 p6 ~- M# Z. j0 \6 z& t(number : integer); y6 h; n; r, v  x
is+ s+ y2 N# j  B; W
do
6 y8 _' a- c& @+ p: i/ W   inspect number
6 \  g6 ]( w. V& _) {* g9 A/ H# r       when 1 then " z8 }9 s& G! r
          print "not a prime number"
& Q* ]' Y3 Q5 T0 Q       when 2,5,7,3 then
$ V. M1 D* w/ |* C  z* B          print "prime number"( @9 g; z3 N7 [& c
       when 9,4 then 2 [5 F- H6 M0 ~' o7 {% l9 F2 z
          print "square number"9 m7 E5 Z, e/ n8 g
       else
/ o* |, s. L7 r2 a* d* X          print "no special number";
8 V( P& a" W, m! D, E$ u          print "or number greater than 9";
0 `% c  A2 a1 O1 C) d) n$ R   end;9 G* j+ Y% u1 V! d& N, r
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-16 19:07 , Processed in 0.140509 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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