设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8658|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is% V6 \3 T5 y* ~4 l
       Ci :integer; qi : integer  S! [# v4 [' w: h0 `9 u" P
do 2 K& d; ]. I  e, b3 ]& A2 [
       inspect Ci
5 [% F: V* K. Fwhen Ci>0 and Ci <=150 then / g; u" n8 x- l% m% T1 \- B
       print qi=1;0 x$ f# W' z3 r+ n3 x! q
when Ci>151 and Ci<=500 then
3 m: ~" I1 z6 @6 J3 ^       print qi=2;
' V" }4 k" Q9 E; l2 Kwhen Ci>501 and Ci<=700 then
1 X( y" i7 l, K4 b6 z' J       print qi=3;; Z3 N; O, W, U$ R- |. B! e) ?
when Ci>701 and Ci<=1000 then" @7 l6 v/ ^* M1 u- G
       print qi=4;0 x* w( P  V  Y7 \8 }
when Ci>1001 and Ci<=2000 then2 q$ e# m; U2 p" q, B1 p$ R
       print qi=5;
7 v9 I9 }" S, }7 j& p1 V- swhen Ci>2000 then
% ?7 v+ N# q3 X. {1 u& T: }       print qi=66 r, n& `1 Z: E3 v" w. F
end;; r( |9 d7 R# ~5 Q( x
end;$ E: }3 ]4 b- _0 h) e
4 E6 J7 c8 U; g, V4 Q' F- S  C
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?) x* l0 C, b5 }2 z0 v2 S' d
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
+ q6 {9 t' r* ^  T( k* t(number : integer)0 s$ F2 J# E/ _4 B
is
& I4 E$ m+ }9 B5 Zdo
* T- h- F! g3 r4 M( j. O   inspect number" `2 u9 c4 z- N0 L) b! d$ C' g& {
       when 1 then
7 n5 }- W4 W8 @5 `& ]4 |9 }          print "not a prime number"
+ a3 e5 y/ X& Y3 q, P0 a1 O6 x( p       when 2,5,7,3 then * e* B# L' R9 t6 `9 t7 V/ D) D$ m
          print "prime number"
" U- W( |- Q' j6 I& n9 R       when 9,4 then 3 `; _0 x" V! H( o' m- C3 }
          print "square number"
7 _7 j" s3 f) w# G; f" K+ t       else8 V7 ?! o7 e" h  `9 k' E, z/ n
          print "no special number";
6 d' I# B2 @+ j5 h$ [6 C          print "or number greater than 9";
/ A; w0 [2 ~: `3 x7 S  {   end;
+ v2 [, c- f1 l) aend;
 楼主| 发表于 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-6-1 07:22 , Processed in 0.012427 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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