设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8081|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
0 O( @5 E+ M* C2 K0 Q* n* j       Ci :integer; qi : integer6 w) s4 @0 j  o& ~$ \) L
do ; E% u: G5 s! x& D6 }2 [
       inspect Ci
( s8 j7 V% g( uwhen Ci>0 and Ci <=150 then
' ?5 Q0 R; K2 T/ g2 q! Y5 F7 z       print qi=1;# D) [' F! ?% |" r# O7 [3 ?" t
when Ci>151 and Ci<=500 then
6 Z5 B2 ^8 [* I9 A       print qi=2;0 j' l% |- f4 @9 Z
when Ci>501 and Ci<=700 then- A; g) ^" w4 Y& d% h9 b  _9 t
       print qi=3;1 ]( U6 n9 n( ^* p7 D
when Ci>701 and Ci<=1000 then/ r& ]/ ~6 f. V' W% Q% p
       print qi=4;
* ?1 I3 x: d3 l: Y- o* Cwhen Ci>1001 and Ci<=2000 then# Q3 m# Q6 m: o3 K% P: o
       print qi=5;8 y- o4 e" T' g& M9 h
when Ci>2000 then
) L" n% \7 b# D; M$ @! i& U7 }( W       print qi=6% i3 K9 o. V& ?9 {" O5 I: s7 q, {/ q
end;2 d' X+ n% O( [5 K" {
end;
+ f% k+ @5 f. I$ c, t
# v* \2 s+ B5 E3 W) E          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
% p# N+ [% p* {* O# ], z          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
: r6 i4 u" D! I; F(number : integer)& k3 q0 e: I- f7 @* g4 p' ~8 N% z
is
7 d) }9 V5 [2 }; u, w/ [" X; \4 `do8 N1 ~( t! z2 @& `4 s9 B4 v
   inspect number
% b# ]9 F& e% D& g       when 1 then
; Z) f0 j/ T- A1 B          print "not a prime number"* t' [2 e/ {% G2 J+ F) c: [- o
       when 2,5,7,3 then & i+ S- O" B/ K, _9 `% g
          print "prime number"
) X7 o1 Q  ^8 Z  c       when 9,4 then
( _& I8 }7 j' `# k* L! v0 A          print "square number"
4 I3 A3 Y" |* X: @4 C. h       else
  }& s2 b& ^% ], m8 L- |          print "no special number";
6 M' p# ~0 P9 W          print "or number greater than 9";
% e; }! g# z4 r! d' x1 q9 {; m   end;
" G3 S( K, w4 f( h' i/ u- R8 W: 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-3-16 17:50 , Processed in 0.015686 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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