设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7686|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
2 [7 I" n* Q/ i& w; J6 V       Ci :integer; qi : integer" t/ F* [5 @0 v: l; `& x8 [. {
do ! O: l1 L* l/ @0 f, K
       inspect Ci6 q" Q/ m: F! O) E( g" T
when Ci>0 and Ci <=150 then 7 S% H* M+ Q4 }: g& j
       print qi=1;: V) H4 |' G( y8 B8 Y/ I$ j
when Ci>151 and Ci<=500 then
% ~5 L  [2 u. z% r0 G, t; l       print qi=2;% m) v' L3 L& S( `
when Ci>501 and Ci<=700 then0 E% d2 c) B' }0 K
       print qi=3;: v% g+ D" ?- ]- \: y! O+ D5 Y
when Ci>701 and Ci<=1000 then
9 i. h7 _' Y& U+ r       print qi=4;- B- A9 [* B9 }) L& o
when Ci>1001 and Ci<=2000 then
# t& P/ `) s* h" [$ {  d5 j       print qi=5;; Q3 b6 n. K9 Q# |: Y
when Ci>2000 then7 G. \: [; V, K6 p# V( m) ?, [
       print qi=61 x0 f$ y  b) P5 u9 @( w
end;5 d, ^9 s8 B3 p9 a% W8 @: r
end;
' I7 s. ?: U# T% O0 V1 w( y. q) s
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?' n  x+ @8 d& ~
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:2 V- w& b& [3 t' X6 O. `
(number : integer)
; Q, M2 Y8 R- a0 P. {is
' D' k& O) ]5 O/ _  R( w3 Wdo2 t& t4 @% P" _# s1 N3 U. H
   inspect number8 ?# _0 i& ^" _
       when 1 then 9 L' F3 N# m7 V9 u2 q
          print "not a prime number"$ j7 a& j0 l" k; {; T8 ^* Z8 d* w; l
       when 2,5,7,3 then
7 w/ B, t* f" I! D$ K: P% c) w5 j          print "prime number"8 L9 G0 W0 ~$ u  J4 h+ p
       when 9,4 then
% w2 ]& S5 u  ^. L* P          print "square number"* X4 ]1 C+ j5 i
       else8 r- Q( z( C$ `  f
          print "no special number";
# |# B) m$ O2 s6 G- n          print "or number greater than 9";
3 `" L- P7 a9 q$ n8 m' S; S# o   end;# J& N  @6 M4 c$ w
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-1-2 03:56 , Processed in 0.015458 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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