设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7395|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
0 n8 E  i6 G% o/ m! k* B       Ci :integer; qi : integer
2 e( ]4 b8 R4 A4 D% r, Q. Y/ Jdo
/ I  D7 i- G5 A6 `4 L6 D! |# }. F       inspect Ci
- i; E) k% u$ k& m9 h0 R; hwhen Ci>0 and Ci <=150 then
$ s, R- _- \6 B       print qi=1;
/ I( g0 D& U3 Y, K$ g: G# s6 kwhen Ci>151 and Ci<=500 then
0 I( }1 y7 u+ g       print qi=2;5 e) q% t. F( a+ `6 F, G/ k
when Ci>501 and Ci<=700 then1 \" w1 u2 I; ]5 q& T
       print qi=3;1 t5 V4 m9 d" G. f, |' d
when Ci>701 and Ci<=1000 then7 N: B7 x1 e# V, G0 h
       print qi=4;/ i0 }( H3 u1 Z7 ]' ]% G* l
when Ci>1001 and Ci<=2000 then
1 R  x- s3 p4 [- F# d' |       print qi=5;
1 w- ~7 W- R2 fwhen Ci>2000 then* s$ u5 G5 B! `% c# X
       print qi=6
4 s8 U7 o7 _- z3 M; nend;9 ^) P% s. O2 s) w, t3 q
end;
2 o4 v/ ^5 ]% ^; y+ Q$ M' j! c# Y# g. }! t2 }; W
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?2 u0 i3 y- ]8 W2 I
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:5 ^7 T- m  J, ^) v0 T" k0 e
(number : integer)* K" M7 p0 o6 @1 l! I6 N
is
$ q/ l( j5 Z# G! Pdo
# e1 h1 z" F0 ^* I   inspect number/ p1 H+ _, O3 a0 W4 Z5 K: K: o3 ^
       when 1 then
8 s: K: I: S; A          print "not a prime number"
9 U/ F( ]0 V7 T: b1 x       when 2,5,7,3 then ' U3 J/ x( Q0 f0 o' G
          print "prime number"
& Y7 c! P* q6 J; Y* o+ H       when 9,4 then
: D2 t  x9 r/ ~; ]1 ^          print "square number"
' }0 S, S+ x+ c3 s, a0 Z       else, e# K$ I  f3 J# m  ]. |5 ^
          print "no special number";
& o7 S5 ?# D: p$ v9 j          print "or number greater than 9";
. r% h$ w9 _3 w4 C. J) z% U7 \! c   end;6 d. _2 o6 C/ K  T$ O  U# T: h, y
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-11-17 00:14 , Processed in 0.016564 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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