设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8572|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
' A$ l. r# Q* F       Ci :integer; qi : integer$ x. c, ~2 b- L+ {! \& ^
do
. y% R' k8 [) h1 y% E       inspect Ci
+ T$ |6 ~' z5 ]2 s: s2 C* bwhen Ci>0 and Ci <=150 then
% [; E  u2 L7 Q; Q$ J       print qi=1;( ]- J9 m1 d4 f) ?# P) D: a
when Ci>151 and Ci<=500 then
0 P$ R. L% z- b) m4 ]# U$ e# l& y* P       print qi=2;9 k  n5 B- J: f4 Z
when Ci>501 and Ci<=700 then
) [4 @% e4 L4 R  }7 _* W/ @% k5 _       print qi=3;
7 t! v  e9 i1 `5 L2 }5 ^when Ci>701 and Ci<=1000 then0 v8 ?% Y+ P; L* ]. ^; p) K6 T
       print qi=4;
& ~/ J9 h1 g" z9 ]) L. L$ K) Bwhen Ci>1001 and Ci<=2000 then
$ i3 c6 F6 M6 P! h8 q       print qi=5;! H, R8 E: z9 c$ J* c
when Ci>2000 then& l! h) _1 i# J9 M) ~3 T* s. g
       print qi=6* f- z9 S' \5 a
end;
; s; Q+ g0 ]) ?' [end;
6 S* l1 g1 y- N# M5 ]
9 F* g0 W4 v; m# i* D0 Q, O+ Z          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
6 _5 i4 V; u! K4 F+ G: z4 i          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:# _% J+ P: T% _- q
(number : integer)( L" J5 Q" U1 f3 |. D  ]# l/ C* J
is8 w. W3 S+ q, {6 Z, Z
do" n: R+ R; T: M! {5 A
   inspect number0 s1 ]6 D" `$ B) w- H" I; j
       when 1 then
" w  w; D6 o; R+ e3 f# D$ a0 K6 u          print "not a prime number"
: ~' U  w7 r' q1 m       when 2,5,7,3 then
! `. y9 l3 _: `. p- Y3 @6 ?( E& G          print "prime number"
2 L! O+ r7 [1 K1 T( T       when 9,4 then
7 `) |6 \2 u" ~/ a  I% D          print "square number"; q6 E" A8 ?. B+ V) Z) v1 y. R
       else
+ h! Z* c# i& Y: p& b/ g7 Z          print "no special number";" b4 S1 h8 z. \4 D% G: }0 ?+ R( U
          print "or number greater than 9";/ J( d+ h( y9 _& g' y6 @2 w- `* b. B% _
   end;: f8 t' K$ p3 N  G" T  ]( 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, 2026-5-12 07:48 , Processed in 0.012822 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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