设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8529|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
* R. C& R( P1 r       Ci :integer; qi : integer  ?9 J3 h4 z  l* y" k" r+ V7 l
do : \' A& P: A( |0 S4 c9 r+ _
       inspect Ci
- I0 }: U/ x% A) m$ _8 s% Wwhen Ci>0 and Ci <=150 then
& R" z2 p2 i, y( F0 L: k       print qi=1;) i/ j% E) i8 i, [9 D
when Ci>151 and Ci<=500 then
0 ~3 l$ C6 f" b7 z       print qi=2;5 ]' |! ?( ^9 w" E' z& A' K
when Ci>501 and Ci<=700 then
9 z" G5 L3 Y* O! D0 C' Y. Q" X1 a& {. |       print qi=3;
; |8 n, y" e# B+ }when Ci>701 and Ci<=1000 then
, r$ B  c9 E0 {& s& E5 Z0 I0 h       print qi=4;
7 Q. \! X6 q, c- A" ~when Ci>1001 and Ci<=2000 then
0 y6 x3 y4 c& {! B2 O2 g4 d7 l       print qi=5;" w- N6 A4 _6 A
when Ci>2000 then- n  e: ]% D+ p; @% _! S
       print qi=6! n" u2 R7 I0 O, |9 L1 c3 ]
end;
6 j7 I8 R4 H' c; tend;
& C4 @& F; N* w& w6 Z# x& `" V: l5 g3 J# @
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?# @) o0 Z, Z+ C! e7 |1 |" Y( t
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
* y6 q! v2 ~/ s2 H( V( @, B(number : integer)
) S6 u. o3 ^. c9 `1 nis# J& b. C& h. g+ p
do8 k- K4 ~) a( |+ x8 m/ ~
   inspect number0 D4 b, ^6 N4 j
       when 1 then   h4 X" b( k2 z; l5 ~1 N
          print "not a prime number"
/ v& h+ I1 d8 e- Z3 B       when 2,5,7,3 then
+ `: d( \4 ^% S9 E+ L          print "prime number"
/ H% }- T6 f5 i3 S9 j       when 9,4 then
  q7 _! H" O( W% m' w          print "square number"
% o3 N4 Q; N% e5 y; j6 M+ Y4 t7 D       else
# M$ I& G+ C  ^$ d4 C          print "no special number";* H" G+ b5 F# h' t' b
          print "or number greater than 9";$ x0 w- j7 W4 C* w
   end;
7 _- ~( f+ W# P9 g2 _. q  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, 2026-5-5 07:13 , Processed in 0.015511 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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