设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9273|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is7 f+ e% n) Q" f5 i3 g
       Ci :integer; qi : integer
; {& ]3 P& N" Y' x1 o3 Y, ldo
3 `: F* P6 ~* x$ K) a$ v       inspect Ci; l( `) n& \$ S* o
when Ci>0 and Ci <=150 then
) `/ c3 u! e/ ^1 x7 M. g       print qi=1;
  e& l0 r8 P  C1 `: b' h0 J* B: Uwhen Ci>151 and Ci<=500 then( N/ [: {% R0 o! u- [8 d  A/ T
       print qi=2;# q, b) W4 E, y: C1 g
when Ci>501 and Ci<=700 then
( Y; d) D/ H# ]2 _: T       print qi=3;- g$ b+ y6 N: `/ f
when Ci>701 and Ci<=1000 then
9 `. P+ W# h* I  M       print qi=4;0 P8 B. ~9 y( h8 U
when Ci>1001 and Ci<=2000 then
* n$ Y! \* N% b8 p. c) Q       print qi=5;
: P2 W* p3 I$ }1 u/ Ywhen Ci>2000 then4 {1 d3 K6 X0 W( R4 h# b% T# C
       print qi=6" Z6 J/ P  S& a9 H, d6 \$ Z& w1 ]0 R
end;  t( I3 `$ ]9 N4 ~7 F6 n
end;
- I& J: P) R5 V2 E; w5 ]
# n/ b) Z" v, j  l3 V4 C. W- `          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?, ?# [% }$ {, R% E
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:. z0 B9 E5 M0 {! _& c( g
(number : integer)6 \0 T1 X4 T/ u" S& s8 G
is
, X8 l- r  R0 ^3 a3 I0 {  q8 @3 }do
6 U9 s4 p# x9 L4 ?; Z   inspect number+ M- L' y# ^4 R
       when 1 then
- h) u* l% S6 V( E  _/ h3 _          print "not a prime number"/ h3 q4 p( z. t: P3 `4 w
       when 2,5,7,3 then 5 g5 D5 l: a( _& V+ U  t; x: a1 @
          print "prime number"
. L# c4 L6 H4 x0 Q0 {! P       when 9,4 then   A2 u8 C& o. |. F
          print "square number"
  ^2 W$ K) V+ T. i       else3 ^1 B7 S9 H  J
          print "no special number";
. g- i: a! |5 I6 }3 S$ h8 w          print "or number greater than 9";5 N0 `- U7 _9 f! g/ A
   end;5 D. V) u7 v+ [# n4 e+ A
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-8-22 17:21 , Processed in 0.013462 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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