设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9314|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
, h- X& |5 W: A4 i       Ci :integer; qi : integer
% U# L( w% ?/ p# o& O+ e, fdo ) Y* V* ~* g- |8 {- ?- L
       inspect Ci" Z; O3 |2 h  {+ A$ g, v
when Ci>0 and Ci <=150 then 8 R& E6 `+ t9 x2 N2 x% a3 t
       print qi=1;( l* G- U9 O2 M% p3 r0 j# |! M1 K
when Ci>151 and Ci<=500 then
( O& M9 v* K3 e       print qi=2;
$ q) u$ C' c' M( Q' Ywhen Ci>501 and Ci<=700 then8 `9 J0 B2 P: s4 U% o  m- c- b
       print qi=3;8 h& Z% N9 e" S. ^; V6 f( [
when Ci>701 and Ci<=1000 then4 n+ A$ K! d, P: R) q
       print qi=4;9 f3 z( i& W+ W+ m
when Ci>1001 and Ci<=2000 then
. ?! Y9 _" w5 [% Q       print qi=5;/ |: @  _: A* a
when Ci>2000 then
$ }, T( r  ^# O2 B- x       print qi=6
/ W5 ?0 F- ?# [8 Tend;3 Z/ H% k" s: j- N" ]- \6 x. Z! E
end;
- D7 R* l( O; b- x3 p* [* A0 w, N5 i5 s8 ~3 P8 W) i
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?$ ?( A) h7 E9 Q; H2 D2 a
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
- \) H6 m* z% c% n  b(number : integer); B2 @5 \7 v8 m6 z
is/ Z* b) c& D/ Y8 O; z
do
9 G8 c, a4 l* T' d   inspect number
' j4 Y2 s' U. V/ M- u* }: {       when 1 then
- w8 [# h' b* F          print "not a prime number"
  Y8 B: M- t5 D, Q7 C       when 2,5,7,3 then - s1 v, k; h# G; s7 t: \' Y4 {
          print "prime number"
1 q1 D' Q* W6 y, r3 }" f       when 9,4 then
; l" b6 \8 y* ?: B2 e          print "square number"
2 }; h* ^, v; X: H/ y       else0 q* t( i: |2 M' K" W, M- p0 j
          print "no special number";6 N5 l$ p3 a1 V" O' S, u7 U
          print "or number greater than 9";' R( a. ~" W1 z
   end;' m/ J$ {5 X2 `. ~  Z
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-8-30 01:45 , Processed in 0.015852 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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