设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7497|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is/ k+ ?* ^7 T2 U0 [- Y, m2 r
       Ci :integer; qi : integer
4 D( G4 k; b, t+ h' n" K0 s& |do
/ z3 Q% V# F0 s       inspect Ci
6 m7 |: Q9 y- y- A0 twhen Ci>0 and Ci <=150 then
8 C" d3 @5 L2 p' K       print qi=1;5 a* ~5 s7 s, K$ N% [
when Ci>151 and Ci<=500 then
# w5 C" X* F5 |, p! \       print qi=2;$ n6 l6 R6 I/ q# U7 t; ^
when Ci>501 and Ci<=700 then
" Z0 K3 ]; S# B$ W- I- c1 o       print qi=3;
3 u) y. }7 f' G* T! q$ `when Ci>701 and Ci<=1000 then3 {$ h5 s  C8 ]; L+ a( C
       print qi=4;
; u* q6 H+ U& p3 S9 lwhen Ci>1001 and Ci<=2000 then
& y% q4 k) R* z4 Y( }  {7 V! J. z       print qi=5;
$ F7 z- }* j6 E' T% hwhen Ci>2000 then9 ?6 j2 N5 N( v  `% I  m
       print qi=6+ j  G  s3 g3 o; L
end;
* N- @% Y, C; Q0 a0 [end;' R3 w0 d8 S! F

) j9 c2 ?$ f. F4 b/ g" _  d          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?: s5 `# M+ f4 X& q" a* k
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
, F! i' D9 H- c- F- c. w- A) |  ~(number : integer)9 P. ]9 s. O& b  t( j: N" r
is
: Q  Z( ?( f. w+ m3 e! Xdo
6 l% Z4 z! n, Z  M- k7 o   inspect number
2 v" q: c0 }' ]3 q# k9 |       when 1 then 1 M$ C+ ?4 k! a! ^& f
          print "not a prime number"
: J& t! n- d/ t% P$ a       when 2,5,7,3 then % v+ {5 u8 {' e- M1 r# C
          print "prime number"
% M0 q9 Y$ D" B1 O5 k# ~7 ?       when 9,4 then   X& e3 S" O' Q  `9 X. j, U
          print "square number"3 y- _0 U2 N1 c! K
       else
5 R, }. g5 D7 c5 j4 M0 w  Y          print "no special number";
4 N2 ]3 g! y' {8 \( R6 K6 J  f. d          print "or number greater than 9";
3 O4 ?1 f% B! ^$ q  h, H   end;* F* ^/ }& ]5 n5 u
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-12-5 14:09 , Processed in 0.013265 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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