设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7763|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
5 p" }* H+ e$ N' e: Z7 J( u$ H( ?! w       Ci :integer; qi : integer
& m- B" Y; J7 k% K" f( vdo & o! d. ?+ R7 P! Q; h9 w- i0 j& i
       inspect Ci# |" b2 U0 g1 f
when Ci>0 and Ci <=150 then
2 O( t3 m% m  K4 P" P3 t       print qi=1;4 ]7 \0 L9 R4 r' e
when Ci>151 and Ci<=500 then
" {' s. Q+ e+ a5 W5 f& z       print qi=2;+ s2 \5 f! V1 X
when Ci>501 and Ci<=700 then
0 T1 I1 Y7 r' u& V$ N' j/ K       print qi=3;
- ~0 U. U; z  c. r0 l* owhen Ci>701 and Ci<=1000 then
0 a5 w3 D. V& R# \% O* M       print qi=4;
% I% w, h5 V9 Owhen Ci>1001 and Ci<=2000 then& A. |0 a) r3 m: D0 n# G: s
       print qi=5;
9 i  }" C2 V) v# Y7 dwhen Ci>2000 then5 M/ B4 P. F% o
       print qi=6
0 c( |* j0 q* F. E3 }% B7 Bend;
+ p0 d* X5 ^* |- q( u! L) Q" w' Aend;
1 Z" B8 _3 U1 I1 x
: b8 u# e1 P) o$ g          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
! G& P7 K' X- z2 t- m0 \5 W          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
8 M( W' @% {* E! W(number : integer)
8 b- m9 W; T! M! {/ Jis
3 Q( F) G6 q. M1 Z2 @: k# ido# V4 k! m5 f! `4 k- A
   inspect number! G3 E, ~7 z/ k" R' x& x0 K% h! y
       when 1 then 4 D' P8 y  u! e$ |5 j  A) [
          print "not a prime number"
8 c5 V* s2 |. I: l6 U* ]8 h       when 2,5,7,3 then 8 x+ Z  V( x, d! H5 W& w, P7 }
          print "prime number"
. {8 o6 a5 L8 b8 \$ h) M" r       when 9,4 then 5 h& V: i% B! H8 ?+ H# V+ S
          print "square number"" O  ?: s& k1 A" c7 D7 W1 s) E  R7 n1 o0 b
       else2 L! d- o% t" C5 d
          print "no special number";
0 v9 m9 K7 V- ?' }' G) p          print "or number greater than 9";
1 P; R- c+ u0 o% f   end;
# c$ N% s% ~! A2 rend;
 楼主| 发表于 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-1-20 18:31 , Processed in 0.017553 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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