设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7971|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is' o8 ?, s( {4 d7 t1 h
       Ci :integer; qi : integer
5 d9 x; t8 M6 o* m, P" k9 Jdo + l. N4 a! R+ p( B( Q5 G$ |8 b
       inspect Ci
( _5 D% I) S4 _* zwhen Ci>0 and Ci <=150 then 1 d" c# t# \, I9 V
       print qi=1;! \2 V1 g! W/ i; q  J& Z! }
when Ci>151 and Ci<=500 then0 F; g# t5 e4 \+ x- g
       print qi=2;0 a) e$ ~' ?/ j; g/ I' h# F8 {9 k
when Ci>501 and Ci<=700 then
$ Y( p, }4 S  f       print qi=3;
6 M( I6 l! X. [/ w0 [' N& W# Rwhen Ci>701 and Ci<=1000 then
- a! d% V! x8 u+ J; c       print qi=4;
+ H6 r- u& Q3 pwhen Ci>1001 and Ci<=2000 then
/ F7 G. O  \0 [, I; D& Q: j       print qi=5;  W0 b. z5 W/ g, y
when Ci>2000 then
( |  R4 V+ [: m( m" }       print qi=65 Q' ]$ E- [9 D5 [: J& F
end;
' F+ ~+ k- _  g) Y. cend;7 b+ R5 A9 C  g0 O" p8 c; K9 J  V  s

' P& P0 T5 m9 z0 z          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
/ _: Q; f5 W) e$ R          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:) w  _5 \3 {1 `
(number : integer)
& O: ?" O: I) U- S$ ^. d8 {# cis
8 D" i- f8 G4 z: U5 ]6 B+ Udo
" z- a6 Z) H8 P/ l2 y9 ?   inspect number0 v7 n0 ~6 [( e" q5 a
       when 1 then
+ \+ R. [; ]" n3 |' v          print "not a prime number"
' T5 W; h1 c  c6 T% @       when 2,5,7,3 then
9 I# m- n: T% Z+ A1 |4 D          print "prime number"4 Y  B( `' b# \4 @0 F
       when 9,4 then 8 _$ a9 V7 C, `, n
          print "square number"
2 X2 o! B3 P3 t* N$ W9 n) b. L       else
, P. O8 Z2 p+ b( i2 d, a          print "no special number";
& m# F- C7 K: ^/ q4 c6 i7 v* G& C+ o          print "or number greater than 9";
+ H7 n+ ^6 ?5 b- {5 s   end;
/ k3 w$ u8 S* g1 D: Iend;
 楼主| 发表于 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-2-24 01:32 , Processed in 0.018727 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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