设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7857|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is6 @+ ?& S2 P  ]! q
       Ci :integer; qi : integer2 y3 Z+ ?# e% o9 ]8 ~- m7 r
do ; y9 V4 N7 q6 ^
       inspect Ci7 {( i0 n1 ~2 G. X/ O
when Ci>0 and Ci <=150 then
" {! d- B0 I+ f7 @       print qi=1;
- B/ {  b; s% @! }- N- nwhen Ci>151 and Ci<=500 then! s! a7 O+ t) d/ X$ A7 O
       print qi=2;
# a% p( p' l! P7 U. R- uwhen Ci>501 and Ci<=700 then
. W. V( X. j1 l9 z6 M3 p! p       print qi=3;; Q: v( |- ~& n. W
when Ci>701 and Ci<=1000 then
: V+ I9 A5 u* u1 k1 ]       print qi=4;% k# s+ P7 K6 V+ P3 o" i! f
when Ci>1001 and Ci<=2000 then% w, ~0 `7 v: z7 o
       print qi=5;
0 ~8 K* y, |, _" Xwhen Ci>2000 then1 C- f2 b; ~' O+ g8 U9 x
       print qi=6
' H, f- o3 N, h. n4 y2 g8 V$ u5 ]end;
" b8 k0 w6 t% ^& E; V% d  Dend;% }) U  c( q( S
: s. d3 S% X9 p' X1 C
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?6 w' j( R0 i% \) X" N
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:1 f9 A$ M+ y; b( f
(number : integer)) K; Y5 F4 p+ Z
is
$ D) I4 Z8 k# Q/ ~do3 r9 j& A$ b# _) q
   inspect number& x8 a3 g0 ~5 o# f) P, ?
       when 1 then + A. T  b9 c, U1 f& J" \
          print "not a prime number"
) R5 Q" E7 O8 j* ?       when 2,5,7,3 then 8 J+ h: j9 W4 O7 \2 F
          print "prime number"
; n# R! G5 M3 i5 V8 h4 n! H* t       when 9,4 then
; G( g- Y+ M! m" }7 A. G& y          print "square number"# p4 ~: Z7 j6 M
       else
. S1 ]% o, k4 h8 I. w1 j( ]$ k) L          print "no special number";
$ z# T5 l) d0 l6 ?5 t          print "or number greater than 9";1 j" U3 H- @! n) n
   end;2 E) a: s1 `; w
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-2-4 23:58 , Processed in 0.013720 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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