设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8742|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is5 f5 h- w0 b: ]& K8 u! r/ H
       Ci :integer; qi : integer
: k& r% y( M5 {' q" K6 C% H; ]do ) b; N# B  u5 H  h) b
       inspect Ci; r' E( E8 T/ ?/ ?, A7 Q
when Ci>0 and Ci <=150 then
# K% O1 @  \. J3 N* m- V% o  ^/ x       print qi=1;7 ~( `5 u- `3 h  R, z
when Ci>151 and Ci<=500 then
$ E( Y4 I1 o' K. _       print qi=2;
1 _6 h8 {5 D1 [, a4 Z3 |when Ci>501 and Ci<=700 then
' n5 M7 R; C4 b" F9 T       print qi=3;: Z, I5 X; ^1 t; b6 o0 `# Y. d3 Y
when Ci>701 and Ci<=1000 then
. z3 {! H$ C& p8 f# \: X       print qi=4;
! C  Q1 O$ |$ `( V0 y, T& }when Ci>1001 and Ci<=2000 then
; P( j6 \$ t8 L) A$ R# g* M% r       print qi=5;! F/ |$ q" K# p: ]$ B
when Ci>2000 then
" S1 a. U5 S- h4 ~% o) W+ {! a! U       print qi=6
( D3 K3 x+ Y) w/ Z3 lend;
5 A: J# j- {6 m' U8 Send;
# ?+ ~' E2 c& b5 S' s
( P; x- {* ?2 G3 L# G          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?( x1 ?( _3 G' `  i4 R, a5 d
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:: F: E6 z# ?: k1 r* l
(number : integer)
/ L8 u. w6 A+ U& L3 [/ Ois$ f, A; g, B  Y. Y
do
  O  u" J/ {% ^8 z+ J- T; z   inspect number4 i$ |6 I! ]; x3 O& r
       when 1 then
, d! E1 w4 G% N          print "not a prime number"( ~3 I2 X; i: A! Z; Q
       when 2,5,7,3 then
7 e# H) C( }% {6 F# U( \          print "prime number"8 y: o1 _1 W' k) g+ l
       when 9,4 then
5 x5 m; f, n8 t/ k# E6 q6 G          print "square number"
9 ~7 Z: {6 o7 z5 M, m4 B( e; p       else4 c4 L4 `% x+ Q% f5 _5 d
          print "no special number";
. ~8 j/ [& Z. l7 K6 H$ A. P          print "or number greater than 9";
1 V8 N. b4 v" [8 E   end;& R8 W$ y3 o7 Z- S/ q1 F
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-6-20 04:57 , Processed in 0.012505 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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