设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7865|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is8 O9 n9 \0 Q- H, }8 s" K
       Ci :integer; qi : integer1 j9 D) n/ {' t  y! W* I% e9 \4 j
do
, e+ R9 y. C: L( G$ B& W" N6 ^, d       inspect Ci
4 T% |( u6 Z; a! Nwhen Ci>0 and Ci <=150 then
) k4 w! B6 n9 w% ]- H' b1 Y9 P       print qi=1;5 T# A6 [, e: k7 c
when Ci>151 and Ci<=500 then
, s1 G; ~  z  p       print qi=2;5 T5 C) X! z6 x# q# z( l& R5 v) `
when Ci>501 and Ci<=700 then
/ e; o' h6 p/ e7 G, q9 u7 A       print qi=3;: N8 n. U. F: ~" D; V5 i; ^  z
when Ci>701 and Ci<=1000 then- e  ^, E) V; U# O& _' m$ t9 n
       print qi=4;
4 S9 o7 B* Q, e/ f3 D" l. s* F! q6 Dwhen Ci>1001 and Ci<=2000 then: w' ~7 v6 L' L& ^/ c6 J  ?! `
       print qi=5;1 s$ G5 m4 T/ Y+ H
when Ci>2000 then
" Y3 p6 a2 \* p       print qi=6
3 g  \9 Q; k- ^end;
# r( D& p+ o! }- {, yend;
9 k, A' @1 e8 C; v: h2 T/ U9 C- Z! m/ X
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
) a% U1 k' [7 ]* l" ]. ]          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:, ^/ \5 w. j) g' i% `) J
(number : integer)6 `4 N0 o$ B% Q
is8 ~* }2 J0 f4 {# ~& W
do0 U2 `- w4 Q! H3 V
   inspect number; u8 V" S) _! ^* U
       when 1 then 5 k/ ?- F: Q# o8 x; y. c! H6 |
          print "not a prime number"
! w7 |% K9 U4 l+ [       when 2,5,7,3 then $ y& U. j2 M1 Y$ z5 u2 O8 ]; u+ i& L
          print "prime number"
, E* F" Z. R, `+ g& j0 J       when 9,4 then
$ f, |; t) W6 J# _  u" t7 T          print "square number"/ j8 g0 _0 n" b. b
       else
! q2 _0 b! G1 n. l9 O          print "no special number";
$ d% w4 R" u( u6 i$ f          print "or number greater than 9";/ y+ z, e0 L4 h1 o
   end;- w1 l4 G' X. d) [& |  ^4 S  \! y
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-2-5 18:02 , Processed in 0.020334 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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