设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7623|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is* E5 N5 T& K. v& ~$ d, {3 q" n9 K
       Ci :integer; qi : integer; l  i& L" i5 W0 o! _! s/ M
do
+ x  t# Z( o: O' ^7 q       inspect Ci5 C2 [9 d* x/ {4 Y4 R$ a
when Ci>0 and Ci <=150 then
' O9 _* V" A5 b" `$ G) _$ T9 I       print qi=1;
3 h# ]# i, W2 u; d. m+ o0 G3 w+ H5 Iwhen Ci>151 and Ci<=500 then
% c% c* y: p6 s/ }       print qi=2;1 U5 P) o7 a  a1 s0 E
when Ci>501 and Ci<=700 then+ A! p) F2 E7 u% a; c3 Z( F
       print qi=3;
* w0 L( f" A; i% Q# g) Gwhen Ci>701 and Ci<=1000 then
; ?; J, `5 R  i/ W       print qi=4;
8 F- ]) l  I# E' `& }) i+ ?/ Uwhen Ci>1001 and Ci<=2000 then% J0 n! O7 U0 j0 r
       print qi=5;) S) n: S6 x$ U- q* ]% p+ u" k
when Ci>2000 then
0 p* J7 ^, `: G) U3 _+ T       print qi=6: ^6 O8 F3 l* O/ z  Q
end;
; K; R3 C3 y$ {) X5 y- u0 Lend;! z5 U+ L$ l* t4 a" k
  L7 h# p' }6 g$ b$ T% y# x( c+ L
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?( i. a$ S+ F" D9 ^2 c
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
5 s0 [. j# M8 o  k(number : integer)5 C# f2 \0 {' H& T; X& f
is
" e1 C( W$ e2 ?5 w" \# i; |! k+ Ydo
2 }1 A. r% N1 Z* F. |   inspect number7 {% w& G1 B% Q8 m
       when 1 then
: u# m6 ?/ r+ j- }' X          print "not a prime number"
7 K( ]( \( q. {/ j       when 2,5,7,3 then
  s7 |" I- I" d% p          print "prime number"
: t" i; d8 j, L% f" k       when 9,4 then % o/ k- _: l, p: W0 q
          print "square number"
2 d0 I) X2 ], `. f       else
! T6 I2 U  a2 N& h& F4 X          print "no special number";2 R' r; Z3 G( V! m+ `2 c, X4 P# F. k
          print "or number greater than 9";
- F6 C8 O- M' V; l6 ^# G: S   end;/ e! Z  R: I* R$ E
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, 2025-12-19 12:17 , Processed in 0.016195 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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