设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8005|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
1 ]/ z$ J1 V7 r       Ci :integer; qi : integer1 z" j( y8 _5 o0 d
do 2 x( g/ a0 V. h& z2 ~( q
       inspect Ci
/ R8 h* n, y. G+ }' n1 _when Ci>0 and Ci <=150 then 9 p2 w5 f' Z) I/ p6 X2 e8 r
       print qi=1;! K% x" |0 i7 n$ R8 b/ k8 t
when Ci>151 and Ci<=500 then( ?4 ]. C4 e9 Q' Q2 l7 Z* P
       print qi=2;' P3 G7 q9 F0 ?3 [
when Ci>501 and Ci<=700 then
% Q3 L1 T, C* Q3 a9 G       print qi=3;2 ^  O1 k! F8 F
when Ci>701 and Ci<=1000 then3 v1 j2 G( H0 w0 q. ^
       print qi=4;
; F# [6 V) B6 K4 y( k0 Rwhen Ci>1001 and Ci<=2000 then; v: j* `' }1 x7 h/ s" V9 d; _% D
       print qi=5;
$ b1 j. k% X- E+ K: Y9 Pwhen Ci>2000 then
6 T/ R2 j5 H' F4 ~- b       print qi=6
& c! C! J# e- J. P$ k! Y/ Lend;9 z1 Z3 ^8 ^0 I# o7 n. N0 Y# j; k. P
end;
+ z. g, G" H; p: n0 w
4 l9 d* s5 e% ?          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
6 o! k1 Y4 t; m0 v1 \8 {          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:9 A: v0 A& F# n! k: \
(number : integer): \' Q4 k: f4 H. f1 M  {' D
is
$ o0 C8 C7 H7 O0 Zdo* o+ T  H9 f1 c
   inspect number; ?6 B% Z$ ~5 P# l+ T5 \
       when 1 then
7 ^* h1 [1 Q" @% A. {          print "not a prime number"& X! J) G% c0 E' n
       when 2,5,7,3 then . ^# m% K( f. {1 s- m
          print "prime number"
; ]# S) E% L+ [3 H, ?       when 9,4 then 0 n+ ~9 W  I/ z
          print "square number": R0 @3 \( G- U/ M# \9 [3 K
       else: L( G3 [" E1 o
          print "no special number";, z+ k( I3 A9 _4 _
          print "or number greater than 9";, M& H2 d* _" x
   end;
# t. n+ G" P; ]5 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-3-2 00:05 , Processed in 0.014368 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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