设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8596|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is; B0 B. q6 S+ k" ?" b# Y
       Ci :integer; qi : integer1 z9 U9 K3 R# r3 `
do
9 M2 s2 _$ c8 }" ~: Y5 Q       inspect Ci5 X0 c7 H5 @: Z; f! x3 `, {
when Ci>0 and Ci <=150 then 9 i/ i' U% d* b' f, Y' d
       print qi=1;; o  K, a2 K3 g+ E* h% g+ @. q+ B  C
when Ci>151 and Ci<=500 then' M- P* p: v0 t
       print qi=2;
" X8 d/ c" v5 P# K0 r" ^: H% ^, Qwhen Ci>501 and Ci<=700 then
, H5 ]  P; s* ^- g' A) {0 b7 {: R       print qi=3;3 J+ |/ d/ g% y2 y3 P( e
when Ci>701 and Ci<=1000 then$ c/ N  W5 I8 d- K
       print qi=4;
" ]* f7 h. j. ~, p# d' }# n: `when Ci>1001 and Ci<=2000 then
4 n( e; E: f& H! S, `. j       print qi=5;; Q# c( e0 i* W6 B9 D
when Ci>2000 then
+ }+ B* u: e) c+ g* q* _% {2 f) f       print qi=6
  v# p. z0 {, d7 g) K1 y9 d) D, [, Yend;4 G+ y- S2 f1 V& D$ y: x" v
end;+ f( A' L3 Z" ~0 y

8 K; U1 c- s* Q' U          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?% {' p$ I. P# G6 x- }  _; ]) I1 ~2 _
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:' p; D2 H% S; `
(number : integer), L% O$ t3 D" h- _8 o8 Q1 A
is
' f- U8 {  z, t( Y3 V' ado1 D3 d; Q' r/ B6 V
   inspect number
$ V7 C8 G4 S' g) w. z9 j       when 1 then
  r, I: ]+ P8 p* U+ |; e* b          print "not a prime number"
+ o% P4 B# M/ P       when 2,5,7,3 then ) o$ L- q  [0 ~6 I
          print "prime number"+ O' P% a8 o; y  Q8 ^( i, _& W3 ]
       when 9,4 then
+ u0 a' \  i) K6 @          print "square number"" e7 [' I4 r: e' l# l) O( O
       else, W1 p/ ~* V# C: ]  ^, S
          print "no special number";
. o' m" W+ b1 J          print "or number greater than 9";, V6 [0 k6 I: v4 `. d, s
   end;
8 g8 ]" k: X3 Wend;
 楼主| 发表于 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-19 08:23 , Processed in 0.016546 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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