设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7656|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
8 I2 F* z0 P2 i, p       Ci :integer; qi : integer1 e1 H+ Y6 ], t+ F; t3 Z
do
# C. F% q- z7 ~& Y, q" `, ~( c       inspect Ci
: _4 T7 l/ N, uwhen Ci>0 and Ci <=150 then
& i* `3 m. b% O! n! m       print qi=1;2 c- N7 g! _% v. [  h* _
when Ci>151 and Ci<=500 then+ l/ Y$ `! O& h4 L( h$ I3 Y
       print qi=2;' L5 ?3 T# Z. ^+ `
when Ci>501 and Ci<=700 then
) k' T1 a. y6 R       print qi=3;+ A* _' Q+ ^3 J, p
when Ci>701 and Ci<=1000 then
/ l5 V1 M8 s7 W       print qi=4;
7 z& R3 y5 r8 p8 I+ M2 ^4 h5 Lwhen Ci>1001 and Ci<=2000 then$ d9 A- X* j1 l( i; h0 w4 L
       print qi=5;9 Q- q7 g' A( i0 Y. O, z) g1 k: b
when Ci>2000 then
$ d3 X7 m5 F2 q3 l       print qi=6
, v* ?' S4 V" |5 dend;/ w2 V' s  }6 ?" |
end;: Q: w6 f" c! J* n$ l

* S0 n$ j8 c- X/ i& n7 b          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
; n! L! l  `, [' }3 t          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
) D. K& Z! s( |' P# n(number : integer)/ u, X% i5 w& k% \+ J
is
* z+ b4 G  W+ x4 ?' X! w8 Fdo1 H& G( R6 H5 n2 D# l& O; e% h% J& x
   inspect number( c6 X) R. B2 x- q  Y0 |1 D
       when 1 then 1 h  v+ B' x+ B+ [: v
          print "not a prime number"( B" v- e9 {0 t$ B* u1 w. q
       when 2,5,7,3 then
2 W  P6 X% D2 I* A          print "prime number"% S% C; g6 l' H2 ]" G6 F, s4 }
       when 9,4 then # j3 t- o5 M( O. y7 Q2 y
          print "square number"6 S  v  j  v- ^/ A
       else& V& d9 _% K; K) o1 e2 ^: R
          print "no special number";$ ?# P! B; N7 v% Q) _$ M
          print "or number greater than 9";, d& H" `* X5 e' }! P$ q0 {6 t+ @( h
   end;
( `0 X7 H% ]/ o% \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-25 02:55 , Processed in 0.019642 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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