设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8684|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
# a: C2 n/ \* P" V& t       Ci :integer; qi : integer
- Q& D- N. p' A. ]. q# ldo $ e) Y& F% ?" b" d9 S! W
       inspect Ci5 ]  T) Q. R, u
when Ci>0 and Ci <=150 then % \9 @: v) m& |; S2 R' a% @2 K
       print qi=1;
4 O- J4 i: `! \" iwhen Ci>151 and Ci<=500 then
! k5 U* b# l1 X1 j. M# T       print qi=2;/ n( v% q0 V1 a! E
when Ci>501 and Ci<=700 then! b+ e8 j- J0 |+ Z& P
       print qi=3;
4 s% x/ R' M" \5 [when Ci>701 and Ci<=1000 then8 N/ v; c$ ~1 j& C( ?% M. j: |
       print qi=4;7 I" c6 P! L) t. Y5 }! {8 I: K
when Ci>1001 and Ci<=2000 then
0 {) H% |" O' b1 s       print qi=5;
3 K' y- O+ I2 _2 F9 C9 _when Ci>2000 then
- L7 [& |8 p; H       print qi=61 E, O; N' x  I& `  c% t
end;( u- `+ g: `2 c
end;
9 @% a" T' U1 [" p0 _: T- r# Q9 Z4 C& F
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?5 I3 @3 g0 }6 `3 E6 r  w1 _: P& v
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:7 s7 c% H  @+ F
(number : integer)3 J3 _4 S9 {* |) \1 G
is$ b0 g, u3 V5 {, w
do' ^& ?+ \# l( A- n" u
   inspect number
3 Z  u9 B1 z- m: ?9 U       when 1 then 7 L& D! C6 y- A- u5 [  x) p
          print "not a prime number"% N" X' N& ~5 T; G3 q: c
       when 2,5,7,3 then
( x" M+ R( X: Y8 [; w! q          print "prime number"
. A/ d; F8 H0 ~  a1 K8 X       when 9,4 then # E4 W1 j9 x+ }5 p9 W
          print "square number"/ i5 R+ O0 {! \. J
       else
) R0 \1 O9 n& [+ p          print "no special number";8 {: ~' X; Q: u$ y
          print "or number greater than 9";
, [+ N/ I/ q' @) }5 ]   end;! a, Q8 e: W1 G- e
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-6-6 15:02 , Processed in 0.014941 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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