设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8685|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is5 A) {6 S- A' A
       Ci :integer; qi : integer: z. g$ w6 S( G- w5 d6 U  G
do
8 I1 J, a# U7 E1 z% X       inspect Ci
5 ~, @1 P1 \* O6 _2 u8 k& t. iwhen Ci>0 and Ci <=150 then + U4 E. X8 ^5 U8 w3 T5 h" p$ ~- A
       print qi=1;' o& j) b; V8 A) G# t8 V) E
when Ci>151 and Ci<=500 then
' }5 o4 D  V* {- R& Y* p       print qi=2;7 b4 w8 a( C& A6 D* V) t
when Ci>501 and Ci<=700 then
/ I- U; [+ g4 l5 Y+ R       print qi=3;& z4 Z0 x9 l% V6 m
when Ci>701 and Ci<=1000 then9 Z. k) g0 C$ l3 s4 w$ F
       print qi=4;
( ^$ a* M  n* ~! `. u6 n& \9 M" q  Ywhen Ci>1001 and Ci<=2000 then
+ o# M! A: U7 _: n       print qi=5;  E& @+ C8 L! m* R, j& O) s
when Ci>2000 then
' x2 J2 h$ |) P       print qi=6
% p( Z3 a- |: q  x. vend;! h; G, w7 p8 ?* ~0 d
end;
( x' m8 ^4 C. M* _' Y8 `
9 e: S1 n4 M$ L7 N6 B8 m/ ?/ o          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?( {/ F8 Z% z3 Y1 T! ?" j
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:- o( K! v) t. y& A2 B
(number : integer)
9 T4 F" h; R& \1 r4 a0 f; zis
2 W1 f, u( V# b2 O+ Xdo
/ I. x1 `3 I9 j& L$ q8 Z$ v   inspect number' W- E) o/ u, T
       when 1 then - V' w  {  F) d- A
          print "not a prime number"
5 p! Z( ^1 a1 o) I' D0 C       when 2,5,7,3 then ; m5 U0 G. l! Q4 Q6 x
          print "prime number"+ K5 M2 z' L& f/ F
       when 9,4 then % B1 G' ~* A" F' i3 z. @0 e
          print "square number"
) r( ]2 H2 e. p- U) @       else
) h( g9 x/ d( e' u7 L4 [- M5 u          print "no special number";2 M# n7 ~+ e& z& E
          print "or number greater than 9";5 h1 o/ k6 p5 l+ l: {7 q- z
   end;8 ]9 [  R: P! M8 \% Q
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-6-6 16:32 , Processed in 0.013063 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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