设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9325|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is* w( P1 ^, [% Z) O. X
       Ci :integer; qi : integer
1 I" ^$ ~8 e+ b0 Udo
- b/ b1 L2 |# T6 K/ ~9 B       inspect Ci
- y2 c; e. I' R# q/ ]/ i: |when Ci>0 and Ci <=150 then : A5 T  U8 C/ E& C. J2 E
       print qi=1;( X" R# D# N+ G
when Ci>151 and Ci<=500 then
; J8 A! q. w+ J- `       print qi=2;
* S" S2 h2 ~2 D: _2 ywhen Ci>501 and Ci<=700 then; H5 ~5 k# ?! M- A: E  ~
       print qi=3;
7 E) h+ q( g" |$ `/ x; owhen Ci>701 and Ci<=1000 then7 n; W4 `4 f  ^# D
       print qi=4;& }6 }: N% `$ F" @
when Ci>1001 and Ci<=2000 then
$ Y* `3 N, W  ~! R# X       print qi=5;
1 N( H8 h5 d' h7 I7 B' M$ `when Ci>2000 then0 O' }: N: n! c* F4 y/ R6 f
       print qi=6/ g/ u/ D* p. _* G+ W
end;/ Q9 G$ ?# w; ?+ p
end;
& A/ n  E! n* X- T" A
# Z# l6 ]' V5 g% @+ g          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
4 ]/ x; i4 L$ ^' d          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:  F0 {, l' C% Q1 x
(number : integer)
" U' L  s/ ]3 Tis
4 W- \8 G2 l) q5 F& J0 `do
+ _" x: o: J6 y6 i/ G+ b   inspect number2 E  f" n5 m6 g) Q8 b
       when 1 then
8 `- G/ I2 K* F9 L          print "not a prime number"
8 e" p! @; k5 R$ j       when 2,5,7,3 then
6 u1 K8 x* T! f/ j% ^2 y          print "prime number"0 M3 E+ y9 s2 R) B9 }
       when 9,4 then
  r. [( d# Y6 U; a7 s( ?          print "square number"
/ t6 R4 w' h' ?: C0 u       else
# b. x7 `3 b: `$ ]: x          print "no special number";
/ S# t$ f$ G, J* A          print "or number greater than 9";" @" C+ P& K% C8 u: v6 ]# V( m* w
   end;
3 e1 [5 w% B! `" F' S" m) O% h4 lend;
 楼主| 发表于 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-8-31 15:01 , Processed in 0.019314 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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