设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7574|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is4 r- i2 l* `0 B7 b
       Ci :integer; qi : integer' R1 [6 u6 K. S
do 9 `3 r) q5 B. k0 Y+ E7 G/ E
       inspect Ci
2 Q0 G/ F& r. m+ Swhen Ci>0 and Ci <=150 then ( _/ ~' j3 \& n* c) K
       print qi=1;
2 i1 {5 y1 a9 j( d9 jwhen Ci>151 and Ci<=500 then
7 g* n3 M* Y' q$ V6 p8 h0 N3 r       print qi=2;( J. p9 R4 t( b  x
when Ci>501 and Ci<=700 then
  Q! e) Z3 W& a7 K' O       print qi=3;  V  b& w. _8 K. w$ B7 ^5 d
when Ci>701 and Ci<=1000 then' E8 B, h* p0 E2 X, ~
       print qi=4;% n5 A+ L9 R7 A1 y
when Ci>1001 and Ci<=2000 then
. i1 {' f/ N$ F       print qi=5;0 L& M, }2 y7 K4 K& f
when Ci>2000 then
# W2 f- y1 y/ H. L9 ^% p. A  K       print qi=6
$ O6 `3 l  L* Q4 s, V  Aend;
% f7 z# e. a  z9 x- A( Pend;! \* V7 o$ `5 ^3 B' j1 q+ _$ Y

" D3 N  r% Y  B0 b          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
7 M5 d0 I% ]5 _* I  E; e0 i  F          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
8 ?; Z* {. O: ?' P* V7 N(number : integer)
8 K0 G+ M" |% N  Cis
: l7 S4 M% l  Q# G: w& ~: j: o  g" Qdo7 g  D$ y8 I% _
   inspect number2 V% U& m1 y2 }% i, T( x
       when 1 then
: G% L$ W+ |& M+ F          print "not a prime number"+ ]" p) ~" D$ ]$ Y* b% T
       when 2,5,7,3 then
! z. a5 z& e( U8 S& I/ T6 Y          print "prime number"* l# k% `  }0 Q. O9 Q0 ^4 z: L+ Q" F
       when 9,4 then
3 r4 Q6 p- E  G( s0 \& x          print "square number"
/ p5 @4 F" v( ~; _3 A, I5 k! G       else
8 i/ W6 I5 U  B          print "no special number";
* D% b( q) M, r1 X' L          print "or number greater than 9";
+ e) e' Z7 i8 C- h/ n& J* F   end;7 ^& h5 Q) K2 @, v8 }# `
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, 2025-12-15 14:00 , Processed in 0.015354 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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