设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7648|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
2 k+ H, h! X6 v1 v& R7 p       Ci :integer; qi : integer) L% ?; b  q. W0 B
do - b5 {$ c7 a; N. H. w7 F: Y/ p
       inspect Ci3 \$ q3 |; `( O  l( C. E2 G: p
when Ci>0 and Ci <=150 then 9 d9 {( @% L2 ], W8 T! L
       print qi=1;7 {+ f2 _$ P1 U. h' o1 ^6 V
when Ci>151 and Ci<=500 then
2 K! M8 H; G  W# X5 ~; |       print qi=2;
4 S, C" Q8 \8 o9 r- c& K1 e. e0 ywhen Ci>501 and Ci<=700 then
5 e; c5 }. ?/ m, h+ k5 w" N       print qi=3;! N8 b0 R- a& b4 m9 q( S, U  V  R9 _
when Ci>701 and Ci<=1000 then& x$ L. q5 x, I; X# l7 z" U2 r/ }  W
       print qi=4;
$ q9 [  {9 H* B% N, \( G+ o" @when Ci>1001 and Ci<=2000 then8 z' S: {# r+ Y; D6 _+ y
       print qi=5;( a% U% b' y2 p2 X4 @$ c
when Ci>2000 then0 y8 G9 S) T6 k
       print qi=6  g. f0 S) S* B4 w
end;
( {- \% R2 C  q# ^  U1 F! ?% mend;
7 w! f- y4 ?$ L, ^0 D  \+ t$ p3 I
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?+ w  R% p0 j  s' w7 X. x  j
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
" ~" s+ {( ?2 l- |) v4 ~(number : integer)
. p7 s% \  X. J+ Eis
2 u+ h- U- p3 tdo
4 ~( W0 |$ O, Z0 u4 ?' M   inspect number
; X# Y3 ?5 f. m) _8 z1 ~       when 1 then $ t) R. S2 h- n2 P  q- Z
          print "not a prime number"
* t8 f! M+ p4 }) K4 ~5 _/ P       when 2,5,7,3 then
3 v: H. U" Z- C, B6 B          print "prime number") {# ]4 E1 N$ ?* S+ {/ v- z$ G
       when 9,4 then
1 M3 R& u$ ?. \5 r, |/ D          print "square number"; v4 @3 k$ @# l
       else1 W6 a5 e( Q: G0 g1 K  v: k8 t
          print "no special number";4 W* A# h8 f9 N% N
          print "or number greater than 9";5 U  D2 n- t$ g+ M% m  o6 |  P8 g1 Q
   end;0 G7 ^9 d5 l  U$ X* ?
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-23 10:05 , Processed in 0.015970 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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