设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8617|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is7 I& k# K8 G: j6 h! |  S
       Ci :integer; qi : integer
6 ^4 l- u! X! J, S* b8 k, ~do
2 S: \- r3 A0 J$ D; X, ?9 j, y       inspect Ci
$ F7 }5 b+ g0 u, P3 Gwhen Ci>0 and Ci <=150 then
! Z( r) v* r! K; T( p       print qi=1;
7 Q5 W; _0 ?: m# b3 P' hwhen Ci>151 and Ci<=500 then
) `6 R" ~- v4 p3 }       print qi=2;
4 w# r  s: q1 q8 lwhen Ci>501 and Ci<=700 then
/ z+ e5 \: I3 f+ }       print qi=3;
- Y& X; s. y; U$ y' s& I; w  awhen Ci>701 and Ci<=1000 then
! H5 O) ]9 ^- J1 t- J0 J* K% s, S       print qi=4;
& R& p& u  Y" W5 p2 Q; Zwhen Ci>1001 and Ci<=2000 then1 W$ o. V" y* h
       print qi=5;
2 L& F  z! x0 y$ @# ^when Ci>2000 then
+ b8 r) g8 c5 c) e" Q. x  w       print qi=6# N8 {& Q3 l- t9 {
end;. y7 a6 l, p+ M! K
end;
& v9 W# C! H1 v. e- S# |1 T1 z' ~7 R" b
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
' @3 `" z; D6 J' `1 W! C          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
) a% r$ P& N8 |8 N(number : integer)
% B9 P2 w' K* v  r0 o) k; zis
) \) y$ y  T7 \4 s$ E# V2 Ddo
2 o( w' j  B, U   inspect number
$ p: g) ~* q: K- O       when 1 then
  y2 @0 u) H9 x2 q- x0 J          print "not a prime number"
& r. ~$ B/ x( d0 [* b       when 2,5,7,3 then
* r9 \# ^- f9 R( r" H          print "prime number"# G0 h2 y' v) S6 o0 b) M0 q  V, A
       when 9,4 then
: x% l& P  q  B* K( i, m+ W  O; H          print "square number"
" w% \. B# F5 q2 W) X1 \       else$ Z! X7 G$ a4 f+ d" d
          print "no special number";
' f0 y- |5 D4 [) o3 A7 z          print "or number greater than 9";
( j  d) ?2 m' J   end;
) ?4 n9 `9 F7 T5 j& j8 O0 Kend;
 楼主| 发表于 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 19:27 , Processed in 0.016201 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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