设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9297|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
" W+ `$ o0 _* R  [2 r       Ci :integer; qi : integer" b  e5 c4 b6 j8 b! F. _! B
do
1 E# e' a$ ?/ C# M5 y. i  V       inspect Ci
) V# M1 V) r4 Z/ Hwhen Ci>0 and Ci <=150 then
. }) Q1 k1 _5 _/ N8 j% i$ n       print qi=1;0 P4 _' z7 z& K$ r$ W
when Ci>151 and Ci<=500 then
; D  l  N0 }  I, e; j5 K# N       print qi=2;
3 n  A4 Q; ?. u: x5 Swhen Ci>501 and Ci<=700 then
6 c" M' X# i" `( o       print qi=3;
0 l: h7 ?  U, U+ ]' Pwhen Ci>701 and Ci<=1000 then
" ?  ]' p9 }* }- q7 S       print qi=4;3 Q, @+ w; i7 g. p, f+ U
when Ci>1001 and Ci<=2000 then9 k6 I5 |/ S  D: s# x- v
       print qi=5;9 n) w6 a+ ~  n
when Ci>2000 then
: n, r% r$ I" E2 K+ {7 d       print qi=6/ x% x; n' A9 r  G4 p
end;
- f5 `4 P: a  \/ nend;7 w; T% {) k/ z% p

& n7 t! U0 g) A6 b+ |# Q          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?2 C; w9 ^5 k+ D7 ?
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:4 X  N. R2 o1 k
(number : integer)
! Z& Q) c* A+ ?is
, }% @$ C! O' U" w6 Cdo5 J9 v1 V$ A6 ?2 i; Z. n
   inspect number, G3 C) X( Q* J' c1 o8 `
       when 1 then 5 U0 }5 k. V1 H
          print "not a prime number"
2 P; {2 O, B9 o* ^! V       when 2,5,7,3 then
' E7 u' R& S4 j' Y          print "prime number"
! Z. Z" A; |* {# G% j! l       when 9,4 then 5 Q( k3 E9 s+ A9 O  H" t
          print "square number"
. m7 s( C8 l, J$ H" t       else
9 z2 @  Y% A2 H          print "no special number";2 u5 }2 ^) l& I$ G
          print "or number greater than 9";3 M9 }# B$ U$ t) S" p
   end;
# d: P  l* I4 q7 c. V. S1 ?+ 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-8-26 19:43 , Processed in 0.013728 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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