设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7751|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is# N. I8 |) H" T3 Y
       Ci :integer; qi : integer) T, F3 z% ?0 @6 f; b* C( P
do
$ {2 K! }7 P6 _) d4 Z0 q       inspect Ci1 U1 ]* e- F, B
when Ci>0 and Ci <=150 then
( g- d4 s* d* k/ j       print qi=1;1 k1 t/ p4 s$ V- F: J4 ^
when Ci>151 and Ci<=500 then
; ~/ l3 ?! E- C       print qi=2;
0 R& X* I: A) u% u# f9 pwhen Ci>501 and Ci<=700 then! @; m$ q3 o/ K; J
       print qi=3;
( w# }+ h( ]* H4 _* w" Owhen Ci>701 and Ci<=1000 then5 ]) f# p3 Z) l/ h# m  w) R# Z
       print qi=4;% v" c+ A& i5 A7 B$ `  K
when Ci>1001 and Ci<=2000 then
  m6 V$ N, g: Q6 P       print qi=5;
  `) f9 |: m4 p9 o  }* W8 n; |6 }when Ci>2000 then8 J, z  S& ?9 F/ J+ V. ?& X) a
       print qi=6! K6 y( K3 J2 w' L
end;0 B7 g3 v& t3 p& Q3 H
end;1 p. u$ L. B  w
' ~' ^$ g6 c9 `
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
% G% k; i6 Z) K6 A. b. _$ q! ]          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
+ R) a& ?1 n$ x# Q# \) R(number : integer)2 N- ]) w4 |- j; h1 X! D- w4 x
is1 P; z3 Y$ g$ r- _
do) _7 j+ }7 L; W7 e; w9 K+ Z
   inspect number! J9 k! o$ f* `" d
       when 1 then
! T) p" F0 ]9 x3 f- P          print "not a prime number"
$ x+ V* F; P0 z% }2 i       when 2,5,7,3 then # Z. i$ c! `! R) L
          print "prime number"; C! V" `; ?* H* h- y6 ]7 w5 f
       when 9,4 then # K+ N8 k7 ^6 m$ Y; Q  V
          print "square number". i& V4 W2 V8 d5 }$ B" j! Z  {! H" q- l
       else7 N8 ]9 x" W7 h! K! s0 j( R
          print "no special number";* H0 `* V4 Z0 k, Z) a5 A! g
          print "or number greater than 9";
+ g) d# V" |/ B. }) u( @   end;
" ~- ]. S* y( E  kend;
 楼主| 发表于 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-1-19 23:31 , Processed in 0.019253 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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