设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9304|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is9 B$ _/ D; e- ~6 c
       Ci :integer; qi : integer
3 Y6 r8 j9 u1 n  [; \8 [0 b' Mdo
& F  T$ D& b) e- i       inspect Ci
% G  X& I3 N0 e1 [7 |5 T: F7 Qwhen Ci>0 and Ci <=150 then
$ v% V2 ]# A6 X& f2 N       print qi=1;
: T+ Q- T# c4 x2 E' jwhen Ci>151 and Ci<=500 then
0 O+ Q1 s7 j: P# ]; |9 Z       print qi=2;
1 y5 W+ @9 |4 X' `& V+ ?: Rwhen Ci>501 and Ci<=700 then8 ?# |- H4 J) f1 ?
       print qi=3;
+ S6 P' |# T! r& ~8 awhen Ci>701 and Ci<=1000 then8 M2 x+ o/ C7 _. E! {
       print qi=4;0 B- y" y/ e9 q! s
when Ci>1001 and Ci<=2000 then* s  u/ J4 E/ Y' L6 p7 g
       print qi=5;$ W; I: I. r$ d) D7 F: r3 G9 |
when Ci>2000 then
- e3 \# j! }* v4 T/ m2 t       print qi=6
6 f  J9 s1 b. I+ Z- Q, g$ R1 m( S' hend;, k2 `9 S% ^: j3 A/ t. r
end;8 P9 m; \; W" ]( l( T5 c  y

, h) w7 f8 ^8 K" r! p          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?9 Z. m# a% H, }+ ?; i
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
0 ^1 e. g" o, d$ i! d& t6 o(number : integer)
# z# A2 [+ k, J5 |is0 Q" _0 z+ u, ^) E) c% A7 q
do0 `# x# g# t9 s7 [! A
   inspect number
% p/ f$ L. Y4 Y0 r8 ^- h       when 1 then : @1 ~- D, }3 ^+ R
          print "not a prime number"& }( }2 k! i: `& O; ]) L
       when 2,5,7,3 then / r: H! S1 Y0 S+ P/ q  }8 q# v; s
          print "prime number": R+ S+ u# \) L2 f) ~7 R* u) G
       when 9,4 then
, t$ _# K7 G, `          print "square number"
8 f4 _* _' `: `% x9 F* N       else" O" R; f! ?, H4 |' k
          print "no special number";
# X( ?& c' k) D' N) ?3 Q# }! q% T          print "or number greater than 9";
6 H9 k( X( A* r& Y" f8 x  `+ f( ]% k   end;
8 g! G: B" w4 W# b! w  Cend;
 楼主| 发表于 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-8-28 03:06 , Processed in 0.013948 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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