设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6586|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
' A. n! P2 Z9 y2 Y8 _$ _# W       Ci :integer; qi : integer, y$ Y9 F3 F$ b" Z4 Z
do
) [- Q% Y0 }/ v# X& ^) ~       inspect Ci" C7 G! L9 t; m6 t/ d
when Ci>0 and Ci <=150 then + i6 T3 N2 L9 F3 T' e$ b! x. \0 ]
       print qi=1;
8 C6 L% C. }1 Z6 K6 z4 Zwhen Ci>151 and Ci<=500 then4 f( H: W. P# j/ s
       print qi=2;1 {/ P3 O* o+ Q- T" B
when Ci>501 and Ci<=700 then
" z$ S+ _$ |  |  {( S6 b" n       print qi=3;
: [! m" ?  P5 Y: R# rwhen Ci>701 and Ci<=1000 then& {0 p9 R7 r1 W* v
       print qi=4;) ^( T2 ?; G: S* @5 g
when Ci>1001 and Ci<=2000 then
0 I4 G5 D0 M3 u2 {       print qi=5;
4 {% i* p# Y  _' M! R7 S* T, P4 @when Ci>2000 then5 p! V  y+ Y- w& |" _8 I
       print qi=6
5 }* X! j* v/ R: xend;( L+ ^; @6 E+ o2 U. w. v$ N
end;5 r6 E9 x# H. w8 {4 ?. i

6 @9 _, }4 J( B: L# @          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?* ?- [9 E# u0 K
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
+ M. ]( y! d4 `) W! S(number : integer)
  m, k+ T& V4 z- i* Vis/ I& w- c$ J1 j( \
do
3 g7 q2 O* U6 V6 j- p   inspect number: f9 J; M* [6 n% h5 h
       when 1 then   M1 S' L: D4 R2 h9 o3 J
          print "not a prime number"! q8 E- J) M( B7 Q( y
       when 2,5,7,3 then / w, O* X0 ]9 h5 p. L6 C7 n  C
          print "prime number"
" O' J7 l: s1 q6 l# O       when 9,4 then
! a; l  n5 d  T; K, U          print "square number"
& ?3 o* K6 k1 S       else
- p$ q" ~2 A" b, ^          print "no special number";  L* ~6 N$ O" K5 [: P: ~" o6 ~
          print "or number greater than 9";
, C$ |+ Q; C0 d, s   end;0 \# h' t6 o8 R, {9 N/ D
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-7-15 03:57 , Processed in 0.012258 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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