设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7235|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is1 B" C+ z3 z# k
       Ci :integer; qi : integer% j7 F5 j/ y% ^, T( N7 Z6 h1 N
do
. W& J* V1 g$ C' O* W5 i       inspect Ci
1 P- @: n  p* X: _+ uwhen Ci>0 and Ci <=150 then
& b4 H6 Y7 j! g1 n& v. \" u1 C       print qi=1;0 H3 I/ N, q+ J. J/ m: [6 O, T; w: F% P
when Ci>151 and Ci<=500 then6 j: m3 V5 h; x# M
       print qi=2;
- |4 [  i% f6 G) Z7 ?7 j+ N. Qwhen Ci>501 and Ci<=700 then/ }. ]* T/ ?3 I
       print qi=3;
% W1 n: T1 k! o' c/ r0 o: U( _when Ci>701 and Ci<=1000 then
* C7 V0 w) O, h, R       print qi=4;- E: ~5 \' C  f' P$ s$ j  V
when Ci>1001 and Ci<=2000 then& I$ A% F9 K* D! e
       print qi=5;9 t( T# o. q" {3 F/ N
when Ci>2000 then& E. W# t8 n; X6 g9 N
       print qi=6
4 n4 @8 C$ f  @9 w. r6 n/ V3 Gend;; O4 N* Z" v1 W- ^
end;* [) a) C+ \* v- W3 Z

# A4 O2 J. @9 \% n          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?6 j% U* s$ k2 I, w# M5 @" f
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:3 c( [1 x5 h2 s  p3 ~& B
(number : integer); B" l0 r& r' Y( x2 U* ?& b; c
is
' r& G. |% }/ {  d6 O& G1 ^. ]+ odo  \6 J$ R5 p  D6 _( V
   inspect number
2 W/ G* u. t1 M       when 1 then
% @" p. ]' w- m; k+ ]7 n8 w          print "not a prime number"7 U- d' N. w0 X3 F
       when 2,5,7,3 then
8 l1 B+ |3 J+ u& b$ P) U+ b, u1 v          print "prime number". J$ Y# h" J( X. C2 `" X
       when 9,4 then
+ Z" v1 C9 v1 w+ e" P$ ~  T          print "square number"
- M) N+ m) S5 G  W" N+ `% ^2 z/ G       else
# E* |1 ?, O5 g" M+ h; Y          print "no special number";! K% g4 z- H( `; C" t
          print "or number greater than 9";
  z- I+ T: p$ A, Y/ X   end;. P1 H0 z4 p# K
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-10-28 21:10 , Processed in 0.016609 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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