设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4575|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is  W- S, M5 o) |+ a5 t' z
       Ci :integer; qi : integer
, Z) A* V2 q- O7 i+ S' V4 b$ z" jdo ) X1 T9 q, y+ i: }. P+ H
       inspect Ci
( B! o: L( k; S# \- T, ~# twhen Ci>0 and Ci <=150 then   [5 l5 d7 ]. C: q+ e7 B
       print qi=1;
+ p' T* e+ k6 b7 d! z* E4 B5 gwhen Ci>151 and Ci<=500 then
  o  E/ E  U3 E  c9 x8 j       print qi=2;
3 _0 K- w' X' i- b9 w: H! swhen Ci>501 and Ci<=700 then$ I' Q- o* v/ S0 k# `2 \1 w
       print qi=3;
* B5 m1 o5 T2 l3 Y" |  u6 o& Kwhen Ci>701 and Ci<=1000 then
6 u3 M/ A7 [  l8 x& ^       print qi=4;
- G2 I& b5 n4 y3 v; Awhen Ci>1001 and Ci<=2000 then
" h" {2 f4 j" E; e6 W: X       print qi=5;
' x2 e; W$ b, Gwhen Ci>2000 then
9 k, @; b# E& z# C! B       print qi=6, `0 c9 M0 B1 P$ r, S" F( n
end;6 M5 m( Y0 H  k/ Z
end;' Z- I* }& l; k( Q8 I3 v
- O0 ?. O& @7 g2 S8 I9 `7 {
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?) W1 ^8 }# O' |
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:6 Y' m2 ]+ \  U+ X# E) ^
(number : integer)1 w1 ?" m; D  t2 u' H7 n
is: c* ~" W6 T$ z
do
$ G. m) F# Y. t) m   inspect number
# g* I* w4 D- H       when 1 then
% V5 P" C+ I5 B3 t          print "not a prime number"
2 s6 T" Z  P- _: c2 p       when 2,5,7,3 then . G& a1 {9 b. w
          print "prime number"
' D1 }  `! s: V1 g7 k& }8 @( _       when 9,4 then
$ d% U" a  \2 X: a  Q          print "square number"# Z0 _7 V0 h/ b7 T# h; Y% B
       else
" k; c1 X, M  O9 ~- c- ]) V          print "no special number";
6 y# ^: T% [) M5 k# [5 s) V          print "or number greater than 9";
  T- }4 J. M7 K8 o1 ?! J9 l   end;
* i6 l" n- S# `, Y8 O3 Hend;
 楼主| 发表于 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, 2024-5-18 20:47 , Processed in 0.012227 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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