设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8273|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
. x5 ?* l5 ^' i       Ci :integer; qi : integer
" a& }) `) @7 r) Q, N0 U( v: j  K/ Tdo " ^: \4 z6 C4 M  e9 K/ i
       inspect Ci7 d: C: D2 G7 z  r( N  W6 P* {
when Ci>0 and Ci <=150 then & O; O# O9 E+ I7 H  ]
       print qi=1;6 Q+ w+ {$ }7 m' c+ V" J
when Ci>151 and Ci<=500 then
6 M' I6 Q7 I' c5 H9 f, C* P       print qi=2;! o. ~  l! y7 ?6 S. y! ]+ G
when Ci>501 and Ci<=700 then
+ d) |" X4 ?2 u4 s       print qi=3;. M! D9 \; P+ o3 o
when Ci>701 and Ci<=1000 then
5 o- I) x1 x; q, V2 U* O- M. V       print qi=4;; z4 F) o; F8 R0 ]1 i( O
when Ci>1001 and Ci<=2000 then8 X7 L3 s6 H4 W* d/ v
       print qi=5;; r. g6 i: t! s' \+ S+ V) N
when Ci>2000 then
: f6 m6 G/ M5 w) B; K       print qi=6
) _  d# i" ^, d+ u- f. F, s, J, c; P( h: Vend;# R  y/ Q) R4 d% n0 n! w3 h( t# L
end;
  a. \4 g, N! s) [
! L  N$ G3 j& A( f          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?  O) O! L3 Z9 n/ n# U
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
- G1 m9 Y) T' W2 Q' h(number : integer)
! a' b- H+ d, a2 Y) {. ^* W3 Lis
! \! p1 [7 u+ X" J) {% J, ?! ^1 {do( S1 Y5 A/ C( \8 S( U
   inspect number
% u0 f% t* X5 T! f) J       when 1 then $ X1 w6 l' H1 ?1 M
          print "not a prime number"
+ o2 P- J/ w5 j1 _1 A: n       when 2,5,7,3 then
9 e) c0 {4 \8 ~+ P( p          print "prime number"
' F! B$ b( \( i1 W. B) H4 [9 Q       when 9,4 then ) P1 y6 e0 u7 w9 e1 `& J' a6 l
          print "square number"$ P( B4 W$ [( |
       else
% ?3 w( m0 z+ M! G; }" @3 \; F          print "no special number";
7 ~7 @% k7 J* I! `2 g; G, E          print "or number greater than 9";/ S, k/ L% R) Q, w0 O2 g( x
   end;
4 C. k: L7 b' Y7 U' h2 Pend;
 楼主| 发表于 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-4-12 06:42 , Processed in 0.015317 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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