设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9355|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is( K# i& J1 H# I2 D6 x" Y* y
       Ci :integer; qi : integer, I) G2 K: A+ O
do
3 `5 E% z6 u9 s6 c" H: z       inspect Ci
2 O0 ^* u4 F' S5 E' Jwhen Ci>0 and Ci <=150 then
$ k  `% U; k' v! f6 y. P3 @       print qi=1;
; P  ]* t9 u, B  M; C7 S) Dwhen Ci>151 and Ci<=500 then* c& d  H5 Y( E0 k: e( e5 g3 {' r
       print qi=2;2 E. D, t6 B5 U9 {3 \: X* \
when Ci>501 and Ci<=700 then. U* x- t7 J  A$ T
       print qi=3;% e+ M: w) E7 z" {; q8 w& ]
when Ci>701 and Ci<=1000 then
4 ^4 H5 d$ `" Q; S       print qi=4;$ H- E! X% H! p: |
when Ci>1001 and Ci<=2000 then2 q2 D! N5 p$ P: W/ \0 a) |; I
       print qi=5;2 `! f6 E0 Y! k6 O0 a: V2 V
when Ci>2000 then" ]+ D8 Y: k2 d- W
       print qi=6, v3 g8 I; z5 l4 }
end;
- t5 b2 \6 [4 c1 k* W  f$ Iend;6 o2 e, z  N& Q

# }' _1 g1 }0 [, m* y          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?+ m4 ?3 T( F/ {& W- U
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:( q' h, X: y! L  n4 p. ^& j
(number : integer)8 V' @4 M$ ^) y, m
is
+ l. Y4 `' s! ^- i# Ado% Y, f- I! F/ y# s/ X- u, ~
   inspect number
. f) v5 |( _1 M8 x9 r: j       when 1 then 1 C' K  ?3 Z5 w; `
          print "not a prime number"6 G% z& a: W5 k* u
       when 2,5,7,3 then
8 @- {1 [' c0 r6 M          print "prime number"( S/ g7 A% ?/ C. i  E* {
       when 9,4 then 4 K) ]9 j4 w, T7 v0 a& R
          print "square number", |, h( E  A8 C- K! l
       else
! e8 k9 ?' U& N, Q          print "no special number";
# s. I3 n' ?9 y! `! h$ E: z/ a# s          print "or number greater than 9";( G1 v! U9 R" c- q- P& ]: [1 \) ^  @
   end;
/ _, L- @) D% E7 C( g9 i9 `5 M/ Bend;
 楼主| 发表于 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-9-6 13:26 , Processed in 0.017158 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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