设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7946|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is2 l+ }# Y7 i1 L
       Ci :integer; qi : integer
2 m- O5 V! W0 B8 q. O" T8 T! tdo + {; X* O  R; U3 Y( d
       inspect Ci
4 ^3 b$ {5 R4 U5 Mwhen Ci>0 and Ci <=150 then ' \3 V  B+ o5 N. B
       print qi=1;
7 M; N1 O, q; [( J' `when Ci>151 and Ci<=500 then+ F  ]$ n/ Y% c" D. n5 G
       print qi=2;# H$ D4 A. }6 u
when Ci>501 and Ci<=700 then) m9 u* T* g3 p. D- F2 V2 ^
       print qi=3;/ }# f: `- `* `, ^4 Z- [2 c* T
when Ci>701 and Ci<=1000 then7 ]8 u5 \- h; f+ A
       print qi=4;
3 O9 d: c3 P. p4 twhen Ci>1001 and Ci<=2000 then; d- y1 y' @- @
       print qi=5;
3 i4 ~, t. |3 owhen Ci>2000 then
2 \, A  z9 ~- i, _1 s1 [' ~4 @+ L       print qi=6
, i( B6 P1 a+ @  N: N& d" K, Vend;* d4 M, S" }3 a, }$ M3 @1 S
end;
' h* ?- `2 y8 e* }% J1 ]2 O
) @- a5 D+ M( I( A8 x8 D          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
6 U- h+ G, z& W) l          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
8 N3 G5 ?5 u5 o' G5 Y' O& |4 ?. r: p(number : integer)) W9 L. z, ?6 Q& d: b3 q9 o
is
: C0 b9 p6 d1 v6 A6 E; tdo
7 T" }* f+ F) u6 w) _. L8 I( z0 v/ z, |   inspect number
$ v% s$ `" @) J# |! g3 J3 O       when 1 then . J3 _4 z8 |6 v4 `) Q
          print "not a prime number"" A: g( \/ m) ]6 A& h
       when 2,5,7,3 then : h3 F2 ^1 \9 P+ j- q9 \
          print "prime number"$ W! K) w: Q( H! P- N+ D7 F) v
       when 9,4 then 1 q9 S5 T- o; O% x$ U& n
          print "square number"1 K4 W- t4 _; S* @6 X
       else
4 ~8 j3 Q; k, Z; @9 T          print "no special number";
6 G6 S: s. d3 k1 i          print "or number greater than 9";. R' w, W# i2 n' k% _
   end;
4 I# Y& p' |6 q' i4 D. ?0 G; \% i, Eend;
 楼主| 发表于 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-19 19:49 , Processed in 0.013280 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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