设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8751|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
- D7 U3 W! x+ A, S/ e$ C       Ci :integer; qi : integer
8 p9 k! W- p6 Q0 ~do ! b7 D. j8 R. t( A: K8 c! k6 M' b
       inspect Ci
" r8 x' ]& w' t+ B# v; u( ywhen Ci>0 and Ci <=150 then / h  C. v( M% }$ T9 r. W8 F. N0 f  W
       print qi=1;
+ I; m3 l* M& b: B* y* ~when Ci>151 and Ci<=500 then( N1 P) o$ J; q8 j, l
       print qi=2;
. ?: H' E4 e9 H+ @/ X% kwhen Ci>501 and Ci<=700 then
1 Z, Q4 K2 L$ a. W4 d       print qi=3;7 v. ]7 @; i% ~8 W3 P7 s
when Ci>701 and Ci<=1000 then% f) W& U: c9 t0 E) G7 `5 U
       print qi=4;$ P0 R# n' a; t% z  c
when Ci>1001 and Ci<=2000 then2 e" N3 c! }7 S
       print qi=5;3 D7 f6 D" g0 {' G/ N
when Ci>2000 then: L1 I) C& w; q! U9 v. }% `
       print qi=6/ t. }* i5 O' L/ n; q$ \5 k: x( m, N
end;
- Y( x+ c; J) V. _# t  {9 Uend;  w. K: I  N, T& C8 w

9 V2 M& z5 i( ~6 ]% E! z0 b          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
  [2 n1 w$ ]8 B' n          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:: ~& Y9 O7 _0 j7 R4 e' k- O$ E6 h
(number : integer): g4 V8 e7 r5 C3 Q9 |
is! E1 D( k' G# z
do
, Y6 b/ H( E- d  U# a  M& G5 Q$ `4 D5 V   inspect number4 O9 ^7 Z, m( S: L
       when 1 then : n% w  I, G1 k3 O
          print "not a prime number"& b: ~" ^# v2 J5 Y* F9 F6 v
       when 2,5,7,3 then
7 @3 R8 n% N5 T. b& ~: ]          print "prime number"0 m* O# h: r. N
       when 9,4 then
& L7 r% L/ F$ E, q, b          print "square number"
3 G- i* F/ {0 S; Z; |$ s; F       else/ ~, s2 f6 T1 T9 V; r1 E+ Y
          print "no special number";
: I3 k: o" s) h          print "or number greater than 9";' [0 D" c8 g2 E0 A. _6 ]' `
   end;! P! t. x: q4 b7 H5 W% p
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-22 08:02 , Processed in 0.014178 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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