设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8588|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
0 Q' R% c8 z8 ]8 |* A! S9 h       Ci :integer; qi : integer3 e8 b* G& N  L8 Z, V; v% h- w6 I
do
! [" G$ ?' k5 l& r8 n       inspect Ci
$ T' [- w* h; {2 U# t! g8 ewhen Ci>0 and Ci <=150 then ' I/ {; W2 k5 U8 ]" [' h. G
       print qi=1;
( Y1 }+ G7 u- y% f8 A& s4 C% J& fwhen Ci>151 and Ci<=500 then5 O( U( B) a' M
       print qi=2;: j$ w: r4 p" F  v: R4 A
when Ci>501 and Ci<=700 then
- y0 a; A" `/ g, `# X: Q       print qi=3;
1 J8 t2 r! b3 g2 R( uwhen Ci>701 and Ci<=1000 then
$ D0 i+ I8 A! m$ v       print qi=4;$ e: g; X3 x. n! i
when Ci>1001 and Ci<=2000 then0 y& C3 K  a6 X$ V, V; B
       print qi=5;+ Z4 Y0 P2 n! t0 o$ ~2 j
when Ci>2000 then
. `  V& t1 Y  B* a       print qi=63 F" }, w, B7 z
end;5 v3 m. u( r6 B+ [3 G4 r3 u' g
end;; J4 Y6 K1 c& b5 q9 X
' O' }1 t- r  s/ S7 q& f
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?0 L, ^& ~* n" a2 A( X* F' {: C7 r
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
- q. L* K% j8 w, Z! H! R(number : integer)
. B5 B( d; F+ b* `/ _1 F* tis
0 O* l9 l3 k, n; @do. d3 s/ `0 s: s  f, V: q# D3 @
   inspect number+ W- X- [! |( f9 B. `3 e
       when 1 then 1 \: ~; e5 q/ ]6 D
          print "not a prime number"
7 b: P/ ?9 m, F4 ?; @3 K. @, C       when 2,5,7,3 then ) B% g0 f: a$ E
          print "prime number"( w$ N- ^0 u6 K1 f5 v" e! |
       when 9,4 then
( i; G9 a4 U& W7 O# g/ m; @, W- @          print "square number"
# V" f0 A; t0 B9 ~7 v& t9 x# Y% D       else
. F& j8 K; \. Q1 i/ }; n& V          print "no special number";
. H1 ^( z& F/ x* T  [+ u/ v6 `( {          print "or number greater than 9";
" a. U1 t' t5 g; ^2 N- Q   end;+ e1 N( r" I( S. E% h
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-5-15 16:31 , Processed in 0.013914 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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