设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8651|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is; t& }$ a  P/ Q* Q
       Ci :integer; qi : integer
$ \0 _6 G0 X  |4 [do - d' D% V0 l; J! \* K% U7 @
       inspect Ci
9 A9 a6 s% ^9 R, p+ u% O9 M! U( T5 `when Ci>0 and Ci <=150 then 5 f& y1 j+ B6 o2 |
       print qi=1;2 l7 z& ]6 Q, R- n! H8 R
when Ci>151 and Ci<=500 then
" c* M5 u& g: ~3 w6 P) G       print qi=2;
9 {0 e7 Q8 N% X% Swhen Ci>501 and Ci<=700 then) g/ O/ q: f1 u" R# h
       print qi=3;
# o/ a  \! }1 P* Bwhen Ci>701 and Ci<=1000 then& p5 d: I5 H  f( R- }* T
       print qi=4;( q* @) i, O4 r/ H; [* b6 F
when Ci>1001 and Ci<=2000 then' P$ a: m' X7 A& V2 ]
       print qi=5;
( I# M9 c* c- ~5 X1 ewhen Ci>2000 then
# u' N, m4 M( Q& H) j- X       print qi=6* P/ Q0 ?- [# j$ S
end;- J2 S! z- Y5 F) {6 L; W
end;
: {5 k6 S2 z7 {! R( E% E8 q
1 p! r( y6 s4 J# N3 \& b, H          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
2 A4 o' c; ?5 q$ Y1 w          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:4 t  ?6 N2 A/ @! j: L
(number : integer)
  X( x0 n# m: G* C$ l" wis" Q1 F3 J# U! W; K  u. j- F
do
* P$ A1 ]( l9 n- T6 p8 \   inspect number
5 P" ^% F8 s$ N' q+ j( ]  p  `       when 1 then
. d- [! K+ Q. Z          print "not a prime number"& m( T. A% g! D9 v6 T0 Z' M
       when 2,5,7,3 then
# Y) L& |1 o: i% x: g2 m7 [, c          print "prime number"8 S% g8 b( g6 S1 o0 k4 ?0 u2 R
       when 9,4 then
, S( P4 }8 |& v, z: f          print "square number"
( o, t9 M; S( }: K( a; b       else
4 W- l) J. ~% j  I) ?" {: ]          print "no special number";6 n# x: |" b2 C0 p
          print "or number greater than 9";- x1 w! J9 V* r: p% Z, G1 t
   end;/ ~& b3 N# W8 E' X& x, \6 \
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, 2026-5-30 15:48 , Processed in 0.016246 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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