设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8635|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
' X; ]# Q2 h7 Z+ N       Ci :integer; qi : integer& U- f( m4 u  a. i
do
1 e/ J. T0 p) d: Z5 M       inspect Ci% v! Z! t4 F( C7 [9 h
when Ci>0 and Ci <=150 then 4 E# B0 C/ R- N3 y# C/ T
       print qi=1;8 x9 j) c5 R" \: j* c
when Ci>151 and Ci<=500 then3 P7 N0 S+ q/ {. p. `3 j
       print qi=2;
! `' o& ?& n( y8 Jwhen Ci>501 and Ci<=700 then
9 `, F7 v% S& j1 Y+ r& m8 H4 h       print qi=3;
- U; X1 P  ~  T, Qwhen Ci>701 and Ci<=1000 then
% G5 \. f1 l( E. c) D: u       print qi=4;
. f+ X+ l% S, d8 _: mwhen Ci>1001 and Ci<=2000 then
+ [7 J  _! v' `& F3 h2 p+ x       print qi=5;: k/ i- \$ ]8 P8 p, x/ O; ]3 l( A5 [; ^
when Ci>2000 then" j. b1 y. y2 |: i5 t. Y( n( g
       print qi=6+ Y- a: Y- j# J
end;
+ A! u6 U1 {% }end;4 N- N# j  k0 y6 S7 ~
  @' }' @0 Y! N+ ?9 x# e8 M' r
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
; G7 Y, w  D9 S; a          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
7 x2 {3 w+ t. ?; [(number : integer)3 D- ~* c$ g; u% r4 \
is
* L) p# r  o& N& ~$ v6 \do
! b. M' g3 D& T" j6 I+ {   inspect number
& s( P- q' U1 q$ e- T- V) i       when 1 then
. H$ d& }, g3 O  w0 |/ V1 f% R          print "not a prime number"
' Y7 o9 ~3 z2 G6 N$ W1 |0 w       when 2,5,7,3 then
+ m" e8 p5 o/ I$ o) J0 A+ q          print "prime number"
. }1 c( D& q, z0 c: W1 ?7 \  b       when 9,4 then ' q# W- b$ H& J* ]# p: T) @
          print "square number", T8 C) B1 e, _+ Z
       else5 u7 w& r, y# m" h8 R1 @( t
          print "no special number";
& v0 m% g, R, J( f% F  z8 i          print "or number greater than 9";( X2 ~4 s: L( x: B1 z
   end;
3 O6 ], f% j( p. J( Q, A9 P) kend;
 楼主| 发表于 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 15:25 , Processed in 0.018341 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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