设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9242|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is0 V( U0 J9 L2 C+ A, i
       Ci :integer; qi : integer  d9 z1 ^5 S0 V1 j) i
do $ u3 V$ p$ M9 h; z2 m
       inspect Ci+ e( V! |  I+ t
when Ci>0 and Ci <=150 then
# n( b- u+ u! C$ s2 ]5 Y       print qi=1;
3 U& `4 c; f: iwhen Ci>151 and Ci<=500 then
1 e: O* O: Y8 L' m, N       print qi=2;' J7 j5 Z, N' P* X. b$ n1 l) {
when Ci>501 and Ci<=700 then" o' j. y) @* C# E3 ]
       print qi=3;' \/ B$ W- w% C% X. w, y! [$ [% N
when Ci>701 and Ci<=1000 then5 C, Q/ y/ [, S1 P' V
       print qi=4;+ E# v. f4 y; [) b
when Ci>1001 and Ci<=2000 then
( o% {+ Y' S% B: u       print qi=5;
3 R* O" c1 q: k5 f3 m; lwhen Ci>2000 then2 M0 ~6 l- c# w% ]1 F' Z" ?4 W
       print qi=6
$ _* Q! [! ]5 }0 u9 N& wend;1 N3 G7 \4 Z9 i# H" c5 A
end;0 r# j! ~5 G' i; s! D
; ^( Z1 ~4 E" a$ y0 C) Y
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
' J  \/ B* F5 Z. {          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
! A0 b0 n( d3 O; Y, P) M8 y(number : integer)
6 \" c! J2 O6 Y7 n& Ris7 ?! E0 T; ?7 i9 _* O& n! B& |  d
do
& C& b( o, `9 d' L5 @; H   inspect number0 V% O; M! [* ?! c
       when 1 then
3 Q9 t( c& s. X' B" {8 x, h          print "not a prime number"; S* S# v8 @# L' x& c. i7 |2 Y
       when 2,5,7,3 then
! G' G& C/ L5 y6 R9 C( ]          print "prime number"8 Y1 I4 |3 {, E
       when 9,4 then
( u- e$ Z4 Y5 o7 O% w8 @          print "square number"- L) k3 g7 F# G2 |% W& l
       else! _) G4 U) c! Y) d" d
          print "no special number";
9 J/ O4 j3 r7 q8 ^. w8 D& o          print "or number greater than 9";
, D) R% n- T- P4 g0 F# ~, t   end;" K3 n/ c% H4 I/ \4 E+ Y* p. Y4 f% 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-8-17 14:05 , Processed in 0.016764 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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