设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8819|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is4 I$ [9 P8 O5 _1 E9 b' s
       Ci :integer; qi : integer, P, _& Y3 v% u7 s. }
do
1 T  Z4 t8 B1 [$ K) S       inspect Ci$ O8 d+ t* V) y' u& T# k2 v
when Ci>0 and Ci <=150 then
$ n# G, @. i4 W. u) W       print qi=1;3 }* L  I7 ]+ ~# ?" h
when Ci>151 and Ci<=500 then) l. H; P; k0 U, i
       print qi=2;: ?% U/ x! r" ]  S8 B" S& l
when Ci>501 and Ci<=700 then+ g6 s- B, l4 i5 C
       print qi=3;
) X. N" I1 `3 P" o) pwhen Ci>701 and Ci<=1000 then
8 S" L$ F9 n& z- o) k. J) I5 f! N       print qi=4;. x, d% R( _& b" {/ S3 M, ?
when Ci>1001 and Ci<=2000 then2 {4 @2 a; t1 S8 ~; q6 F
       print qi=5;& Z. Q- i0 G! c3 R7 p
when Ci>2000 then
; U+ |( T0 e* V- i( N4 p! h6 z, g! I       print qi=6+ \& C8 n1 r- o7 U, E3 y: |
end;
8 d) _# P. c3 G' N$ {4 zend;! ^5 e$ g. o; i8 |3 I1 x5 A
. v! `0 p9 }0 L& s& O* @
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?7 |, m  L6 W9 l# o+ I1 s, k. d8 B: I4 P
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
4 E% P0 @! r+ E(number : integer)
4 J1 p8 a% i0 g3 m" D* B4 ~is0 V% X4 y$ ~9 O
do
9 m$ F4 ]( i( e* }   inspect number( i0 ]. B/ |$ [
       when 1 then / y9 X$ G' B( n! }
          print "not a prime number"
' k9 r/ D( l; Q7 `# K* T       when 2,5,7,3 then
$ C" S# m& U, U# A: Q          print "prime number"/ _, p4 O1 y# M# s# c
       when 9,4 then 7 E6 J$ b2 y+ {7 e; r
          print "square number"8 U8 u& ~3 g9 C0 Q/ w! {
       else
8 a) N7 }# d( [- I6 T8 V0 S          print "no special number";% w# @' X! b& }, G& X
          print "or number greater than 9";9 y) \$ p# M6 R, w) V
   end;
, N3 V% r' {5 @1 ?& s5 o& jend;
 楼主| 发表于 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-7-6 11:30 , Processed in 0.016430 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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