设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9442|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
8 I, h+ h5 V: t9 e* {- k       Ci :integer; qi : integer) b" C6 Y  R: B8 E
do 7 ^% z, ~% v8 |( }+ K  q, @. P
       inspect Ci- p- G4 o) }1 X1 p+ y1 E
when Ci>0 and Ci <=150 then 5 ?8 ]7 X, {6 x1 J0 e, f
       print qi=1;
( ]+ {) C6 L: iwhen Ci>151 and Ci<=500 then1 v! U3 C; K, Q! y" e3 w4 d2 N
       print qi=2;- O$ ^3 P" m. N
when Ci>501 and Ci<=700 then8 z8 K( B9 V+ D" C5 d( A
       print qi=3;7 Z. [8 e* U$ p. G7 l: R& }
when Ci>701 and Ci<=1000 then
$ g1 c( B4 O& \( w+ B. G       print qi=4;
0 E3 D( a' t: c$ @when Ci>1001 and Ci<=2000 then1 ]' e. W8 I+ \9 u
       print qi=5;+ S" d3 T$ v9 b4 L5 u
when Ci>2000 then( d5 I. w& X5 k; N
       print qi=6! w+ M" d3 `* K& ?
end;
9 U( ^% G" w  H! n$ V1 Q& Y, ?end;; r2 T2 Z2 Z) R* w0 c6 f9 B
4 _+ p* S( Z# h6 g' k" H* a& f
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
! s4 T& H4 I6 u7 M          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:# H7 W3 [0 h; z7 i+ l
(number : integer)$ V5 h+ K* o- \9 |  t* l2 o$ e
is7 o" I" P0 W2 X! |
do
, v: {% I7 s1 ^   inspect number
' s& D  O6 C0 m7 I; z  y1 f0 V( S       when 1 then
1 u) M- H+ H  U( d8 O8 @; p6 x          print "not a prime number"
) n% x: b. H& @! x4 }       when 2,5,7,3 then / [( z9 r: C# x
          print "prime number"
' q& q& h- b8 m* ~6 \       when 9,4 then ( a- J2 R: w$ {: x. u
          print "square number"0 {/ [, w: S% p& C" [8 R+ X/ x
       else5 u  R/ m8 ]' Z* n8 u% r2 N2 F8 r1 B
          print "no special number";6 R) _" T: V  N
          print "or number greater than 9";* q# y: r5 p# d
   end;) q1 @9 [/ c0 u. B2 m
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-9-19 19:40 , Processed in 0.017671 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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