设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8217|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is% M1 q! B: a3 L2 l1 r
       Ci :integer; qi : integer
' t- H0 F5 z  c. R. ~1 c3 Cdo + K/ [- r8 h* Y
       inspect Ci
  |; j3 ?3 _0 z0 q9 J* l  bwhen Ci>0 and Ci <=150 then
, u& Q3 X/ X3 e0 a. k3 F, I       print qi=1;  [2 H( x  m1 }1 E' Q# o' j. B
when Ci>151 and Ci<=500 then6 P! z0 \& Y% n  C* l2 O
       print qi=2;
- D9 g8 R0 X& Y9 mwhen Ci>501 and Ci<=700 then6 I; v/ B! p: w0 w& V) O
       print qi=3;& p, L3 m7 C/ ?$ a0 N
when Ci>701 and Ci<=1000 then2 |, ]) u1 Y- G# {: J, G, \; i: W
       print qi=4;
2 b% o) w0 g" G6 Q4 B5 G3 Awhen Ci>1001 and Ci<=2000 then. F$ a  R: n5 v* }# ^
       print qi=5;
7 q3 i+ u, J% t/ uwhen Ci>2000 then5 }6 @+ h+ b4 \4 X& ]. G
       print qi=6; J+ g5 P1 x# [5 |7 n8 `
end;$ t. P% {- j: ^6 {8 D2 ~
end;$ K5 q# O& `  w1 c& Y# Q& w$ m; c
5 w* _4 [. x/ P* t; e
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?5 i: r# i. }- b4 c; t
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:3 f0 l7 o1 I3 A) j6 P
(number : integer)
8 e4 ^5 d* K% O" D1 t* Wis
( b9 }7 t6 k$ y% l, e+ @% s" |do
, O1 l( q8 \. P' d( l# s5 ^   inspect number  _" b4 m- k( t
       when 1 then - c. W4 a: ]$ u) _8 v
          print "not a prime number"- r" h1 h+ \  ^* |/ f) O% i
       when 2,5,7,3 then
, x) ?$ C" a/ M! x4 O1 ^          print "prime number"
. i2 }* H2 @( f& t/ i# F       when 9,4 then + b/ n' s$ l8 y. i! m! h
          print "square number"% U4 e  j. C% n; t3 y5 R
       else/ {( @" \) _# B0 a5 e2 S2 Q  h  L
          print "no special number";0 l  T9 l6 Z. N, O/ e) _& w; ]/ n
          print "or number greater than 9";& `( K- _* l7 t: u8 W( O
   end;9 n: T3 r( w: S1 x6 o
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-4-4 01:49 , Processed in 0.020305 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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