设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8633|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
; W5 ], U. W0 t8 B       Ci :integer; qi : integer
  F# I! |! q- gdo " J( _# T' t" u* Q$ b+ j) G
       inspect Ci
* Y$ `! n7 {" [) b& gwhen Ci>0 and Ci <=150 then 5 s1 r- o& J7 K2 f6 X' [9 h
       print qi=1;6 O1 I4 G. \% `( o
when Ci>151 and Ci<=500 then
, s9 @& N7 I' U( Z9 k/ F, R* X/ B  i/ w       print qi=2;
9 Q' C+ _7 f* O" dwhen Ci>501 and Ci<=700 then# }" R% S, E/ P+ e5 Y
       print qi=3;2 A  S* m! W  E. ~. \
when Ci>701 and Ci<=1000 then
* G+ `  p: M: S2 Y8 g       print qi=4;
* G0 N7 J) {% ~( ~+ P2 swhen Ci>1001 and Ci<=2000 then. d% B1 o( }7 b* k4 C( p; k- k% c
       print qi=5;# e  b$ L" l% h! w* t; g
when Ci>2000 then9 @2 w: Y" @9 e* i( B  [
       print qi=6/ c. s) U) u1 j3 }8 w
end;4 Q: Q: ?5 \) U/ I7 |- e) G4 _( q
end;6 M9 p) h$ U# i
& f9 O/ e- d- t) B$ I. y% s9 l; q
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
  C) z  Q7 a4 Y0 k          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:; q* z2 `7 x+ S
(number : integer)2 l. [% o* ^; a$ R) @: U" ~+ Q
is
+ r. u. m+ }( w3 w1 }4 g! edo  H/ O$ h$ D( u, F" L
   inspect number
. h: g/ M" ~2 s) A2 q) |9 k       when 1 then
: L9 S) S6 E( i* _& y& n          print "not a prime number"
, @4 c! n- W4 N! D3 z- B       when 2,5,7,3 then 4 D: b8 e) J4 A* Y* u
          print "prime number"4 P# n/ @9 o2 H; |& X+ p
       when 9,4 then ( r7 w; {3 Q" m
          print "square number": ?7 t/ C, `; `4 P/ e$ o% i& i
       else6 [/ D) Y9 w* c# D! X
          print "no special number";
; ?* i' F' t/ x- b7 N; ~# @2 D$ N          print "or number greater than 9";5 p4 T# c+ X: B, b( p$ |9 s- \
   end;
5 P" g4 E  ?# Y0 D/ Nend;
 楼主| 发表于 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-5-25 10:46 , Processed in 0.017182 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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