设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9389|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
, M$ [  B; E5 I. q       Ci :integer; qi : integer! }! }8 \/ Y. s: W0 k$ X! N% c0 N
do
" R/ g4 z% k7 u+ t0 Z; L' I       inspect Ci$ t! r& P* |9 }% E; r) U
when Ci>0 and Ci <=150 then 1 K7 I# ]9 l; t) Q4 u7 f
       print qi=1;3 b+ b% [. C8 z/ b) j" [% u3 e
when Ci>151 and Ci<=500 then5 `  Z/ ~: z0 n6 ^
       print qi=2;1 a( q$ C. x) N3 e' C  s: _! Y2 o
when Ci>501 and Ci<=700 then
( E1 `" b1 G! c! }# l       print qi=3;
7 B2 E* L8 T, ?4 D- g1 Z. Xwhen Ci>701 and Ci<=1000 then/ v. d" u/ x1 n8 S
       print qi=4;
& L+ |7 Q  k$ l; U$ y8 U* W9 hwhen Ci>1001 and Ci<=2000 then+ m4 X& I; ]3 b$ |3 z
       print qi=5;
) ], Y% y1 o( O. g+ d. Uwhen Ci>2000 then! K8 H- z. Y, M# v
       print qi=6
5 B- M" b9 K- G! x  zend;
+ g% t# k3 M7 z6 i) W0 E8 W1 R- i4 g' ^2 ]end;% N& _, j1 ]* {
' L: Z' m1 [4 J
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
" M& M1 t! P  _0 h/ g) N          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
3 p' Y! f" v$ l: j: L8 w- j# |1 q(number : integer)
- x' j  ~$ o# f) D* l% G3 `- S& Zis  N6 p) O3 z/ I& f
do
% f/ k% C5 l. W2 f4 k7 e   inspect number6 e0 y' m7 X" S) }: d% [
       when 1 then * g1 L9 A7 A6 e3 Q! w
          print "not a prime number": i. e  b+ q* M; E
       when 2,5,7,3 then 0 q  A& V" h" R6 m( V
          print "prime number"
0 [6 ]% H+ `) V( M% T7 i2 [       when 9,4 then ; [9 f) Z6 ^7 H* N& M% o
          print "square number"
( e1 f1 S( W1 x6 c: l' l/ a6 d       else: T% r' k( s/ s
          print "no special number";
7 Z0 e4 Q) o6 R9 X! A( Y; E          print "or number greater than 9";1 y. P  I$ H' t% S# [
   end;" t8 K( M# l2 Y9 O
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-9-11 15:33 , Processed in 0.014088 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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