设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7426|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is0 R# D0 Q! Q2 I6 y) _: D- n
       Ci :integer; qi : integer
5 w- x0 _4 b1 D. H& Y- U# O- vdo 0 k% u. a8 K# C* e+ T
       inspect Ci
$ W2 [: U5 i- I6 |when Ci>0 and Ci <=150 then : t  s3 I3 n1 L; }' n1 ~+ n0 C
       print qi=1;
( N# l. Y  V. f5 {5 R) [when Ci>151 and Ci<=500 then  l) K: a+ t& T9 E2 w/ c
       print qi=2;# C" W; n! {9 A) p! T$ }7 W
when Ci>501 and Ci<=700 then
( [6 `; M/ S' F       print qi=3;
  E- V0 A' n& i2 r8 Xwhen Ci>701 and Ci<=1000 then
' C8 ]: L9 m; z. i       print qi=4;
( P8 y; k: ]1 m) ]8 U- wwhen Ci>1001 and Ci<=2000 then$ E6 q+ ]0 h* {3 G8 p
       print qi=5;) t5 @' [  ^6 ~% F
when Ci>2000 then
  u! }' d+ q* L  q# }       print qi=68 R# i4 i2 e; D9 ]
end;
* |$ H+ Y. |$ a6 o3 qend;. p* F, _, @% L( f& y9 Y) b- Z. \

- ~" B  E, `8 Z          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
/ K0 m0 O7 _% \. g          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:/ s# i* \, q+ U8 W0 L
(number : integer)
- q6 X8 D. \: r+ M- E2 O; sis0 q8 Y( l; `& W) G1 s8 y2 y
do
! l4 }5 x# `+ V   inspect number8 k8 v9 V1 O4 w6 i
       when 1 then + z9 T0 V( W8 w7 B; u
          print "not a prime number"
9 a7 ]2 D6 y8 Y5 {* s; F       when 2,5,7,3 then & m" B; i& x  }- ]9 w
          print "prime number"
# H9 [2 q/ O. _. L7 q       when 9,4 then
3 m& i& j' q  w8 _          print "square number"
+ x" F( M: W! r, A$ B& w       else, W: L- S/ M5 ^7 Q5 I2 y8 O) V
          print "no special number";. n7 A/ Q$ y5 i: o" ?- h  y7 _
          print "or number greater than 9";
6 T" G6 t, D" ~' n5 X9 m   end;9 D4 X1 w: t  W1 H& b
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-11-23 03:01 , Processed in 0.021703 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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