设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7673|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is8 B" a7 _4 J. h8 y7 w, o# N
       Ci :integer; qi : integer
* O6 Q2 Y2 I$ qdo
" T( S2 Z$ e! G       inspect Ci8 t. p* S% [1 p4 a4 l  U
when Ci>0 and Ci <=150 then
0 i, Q+ b5 a2 s0 {7 j       print qi=1;
' X% e$ _3 T. ?2 J. i9 \when Ci>151 and Ci<=500 then
$ b) b1 {% r9 v$ B: b7 U       print qi=2;0 E; |6 ]3 R: T& W: g/ \* C8 }
when Ci>501 and Ci<=700 then
/ y( i, k4 N- U9 ?! W       print qi=3;2 i( c9 e- \! v+ ~  g% ^2 h
when Ci>701 and Ci<=1000 then: J7 i" Z, R) {6 x3 L0 k
       print qi=4;
# z  b2 Z5 _3 W/ w. a: cwhen Ci>1001 and Ci<=2000 then
) w/ S- b. D4 E$ F/ m0 ^" K. w       print qi=5;. u/ @  Y% ]2 `* h4 T5 a1 P
when Ci>2000 then. D1 \3 N* {( H( C( m, _
       print qi=6
2 Y" \1 \3 Z$ W0 I6 |end;
( x+ r3 \, E8 ?2 Send;
1 q* ?, g* A! N1 p$ H  m& }' U7 a4 v7 B/ I; n( @% u1 z
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
6 ]$ z4 e# J. H% o2 |8 a5 H# |  t          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:' I! D, q- l) k2 R% ]  A
(number : integer)1 k  d: q- t' l) M% ]& P2 z6 Z7 `# i3 V
is
+ x  @4 b% v% F5 f3 n" f8 rdo3 n  B% M9 s! m  R: p3 J: [
   inspect number. v1 g) y6 G; H! F
       when 1 then
7 Y" J( ^  ]+ |/ r. h* O4 }7 u! V+ e          print "not a prime number": o0 ~3 u) i2 y4 y2 ~9 `
       when 2,5,7,3 then , o, O. Q' R# y3 T- f
          print "prime number"* Z  C5 r/ D3 f% U, J0 X1 p
       when 9,4 then
1 I  a9 q: |) t/ ~& C* R9 X% ~# {          print "square number"
7 P7 R% o( d7 e( I* c8 e       else
6 U9 l' M0 ]+ e% q6 U/ o. y+ S/ X          print "no special number";5 q, R9 v$ [8 C6 N2 f
          print "or number greater than 9";
# V1 F1 J6 z1 c4 p   end;* n7 z7 X3 C7 i% j' `  L! V+ h
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-28 17:07 , Processed in 0.019120 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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