设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8609|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
8 e( [8 ?6 i+ y0 z$ ^3 {' }       Ci :integer; qi : integer
% ~# w( O' A/ `do 1 |4 U8 j6 [8 d5 D
       inspect Ci
2 D0 A  b7 m( Y. f5 L! e+ e  K0 b+ b( Zwhen Ci>0 and Ci <=150 then
! w( b! m! E4 N  A" L2 g       print qi=1;
. [! K* R2 e4 D: zwhen Ci>151 and Ci<=500 then
- v7 F. S9 X. N/ G       print qi=2;' j1 d  p$ j$ r7 \6 q0 u9 `
when Ci>501 and Ci<=700 then
  R0 K( Q4 ^2 v$ @) p8 _       print qi=3;0 ?) I4 s6 T/ r6 A9 Z
when Ci>701 and Ci<=1000 then" B# v* f  P5 A3 d* r
       print qi=4;
4 a  o$ V# I8 Wwhen Ci>1001 and Ci<=2000 then. N8 y" d/ K! N# X: M
       print qi=5;
( @: h3 B2 a3 b3 }  L1 q! }9 X& Gwhen Ci>2000 then
: v% V; G6 o0 {1 T+ L       print qi=6+ W) L6 O8 H( F7 k7 }; z
end;
2 y; E: z& L( L( K) d8 `8 Vend;
( a& ?% {+ c5 \9 N/ Q, _0 @7 \9 E9 Z3 `5 x; F/ Z
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
( [$ W, p3 f1 J% u' E          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:  C; D' p! d4 R, v9 p
(number : integer)
% j: E) c/ b  \, \* Fis) v/ {. S, E' g# g9 a3 F
do& m5 q4 _2 `8 O! O9 m6 }6 Q
   inspect number
  ?* F: s+ m0 E( o9 g9 W5 V       when 1 then & }8 }! e6 U) t4 L: `$ M  d. R# m
          print "not a prime number"& b1 u. n- g! Y: y! E
       when 2,5,7,3 then
" w! y. J( V  e" M          print "prime number"
5 H5 ]6 H3 j7 H3 e) q# L3 B7 @       when 9,4 then 7 T( ^& l2 h( f7 j
          print "square number"
* q5 u* D! _& m- X8 t       else1 Q) X2 ]( n  C
          print "no special number";
* \9 M. n4 d9 P' t* r0 N; w8 d          print "or number greater than 9";' c* `/ [/ ~/ c( ?
   end;0 c( I; W0 C2 f9 G- Y+ n6 y6 B" 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, 2026-5-22 09:06 , Processed in 0.015321 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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