设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7801|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
6 m4 u+ `2 Y. i# T  u3 v       Ci :integer; qi : integer
" Y: o- @( G3 |( z6 Z, u( ido
; P9 _$ d3 n( z; c8 _. e' |       inspect Ci
! p$ E: H7 ~+ f5 w1 ^- ?1 P) Lwhen Ci>0 and Ci <=150 then
8 z, n$ E8 W( N0 S; N7 y       print qi=1;
4 n* o+ g0 {  S- L! cwhen Ci>151 and Ci<=500 then& }! G% f3 Y' m7 t* \" U3 d
       print qi=2;9 |7 R1 `% i* t5 b1 R/ E4 v0 f# B  B7 t
when Ci>501 and Ci<=700 then$ b1 k  x& _5 f
       print qi=3;
( P; w. |8 |; h2 m3 ]+ |1 Uwhen Ci>701 and Ci<=1000 then2 S1 G. Z) V. ~$ H4 v: t% |9 ^/ O
       print qi=4;8 g  b% {4 b7 r1 N
when Ci>1001 and Ci<=2000 then" k2 Z1 f( A/ w& u# d/ L
       print qi=5;' f# x+ C, S8 ^8 ~; ~; P
when Ci>2000 then) |/ P% \8 A8 h% |3 P. ~
       print qi=6" W6 A" ~4 e2 A5 A, f9 g* c. ]
end;
$ X+ f; _0 z4 }! S$ ~* f+ fend;
" @0 H2 E# x- z, Q- l
2 A6 p! v2 v* k* S# c          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?7 u* p3 w, c. }9 g, r" N& l
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:( ~% X( a4 Y- `  L; k$ ^- p
(number : integer)
6 W- |2 H9 a: n, W; ois( k( T+ W$ {$ l7 N9 M2 n9 r
do; K6 l2 d# p; W' v  d  t2 m) L1 r
   inspect number" A4 h2 \$ Z' W: [; R8 ^
       when 1 then
& ?  q- F; V, f2 a; Z0 r          print "not a prime number"
- Q9 F' V( T3 |3 d7 H       when 2,5,7,3 then
! G, G' [$ K/ ?+ p& c1 |, T          print "prime number"
" E7 }) D- X  G& T( m0 U4 I       when 9,4 then . c7 H! p2 v; V* O- S% Y8 z
          print "square number"
1 ~1 G& Z/ T6 S6 Y1 B       else
- r6 V( P8 `6 D- B, ~8 }9 m          print "no special number";" c# z3 e  ~& ]* M' [# S
          print "or number greater than 9";
2 k( j" ~, _( P4 V6 H; e/ o   end;) B8 u" q- k2 D/ I
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-1-26 15:49 , Processed in 0.015189 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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