设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8149|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
9 @' g0 T* K5 s/ z' E       Ci :integer; qi : integer
* O1 L& F) m% l2 cdo # n* N- h/ R2 C/ U/ ^
       inspect Ci
" c7 e$ Q3 D; ]  ^& ?5 wwhen Ci>0 and Ci <=150 then
* n+ h- S! b" {* t! G3 p       print qi=1;4 x6 S8 l- F" T- I$ `
when Ci>151 and Ci<=500 then6 @/ O1 K5 S2 |0 q+ I
       print qi=2;
" s3 p6 a. C1 Swhen Ci>501 and Ci<=700 then+ g, l: x1 V6 O: k  w+ e
       print qi=3;
0 ^  W" C, i. d) i3 gwhen Ci>701 and Ci<=1000 then
, @: J+ S  C0 A       print qi=4;" a" V2 a, x! ]1 o9 Q6 k
when Ci>1001 and Ci<=2000 then
2 r/ P) N8 D. `1 H+ l- y       print qi=5;3 M4 b# s1 X, P+ Z! w
when Ci>2000 then
' J' f. p) ~8 |5 V( m       print qi=6
- Q3 C' V) J9 [( xend;6 A: k3 i5 B# V' D2 ~5 }( y# P+ l7 y
end;3 O) M# \" I- K; g( p

4 Z/ u% t- s! T          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
( j# K& H2 V2 x% ?. N  ]2 e          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:& ?7 z. a' l$ V+ i0 B
(number : integer)% Z( D/ |. k/ Y$ ^& q" N6 D
is
6 x: U* n( v9 _# i+ F4 Ido/ l! q) ^; t* A+ P/ T% }0 e- Y
   inspect number: x! l# T. q: ~
       when 1 then ( I. d, q9 @0 x* l' b- h) R
          print "not a prime number"& u4 w4 D% K8 m% U" G1 \' R
       when 2,5,7,3 then
% w3 v2 `0 A; E" A' y) b! p$ a* ]          print "prime number"
2 }  i( {. `3 V  E/ Y8 i       when 9,4 then
6 q( G! E3 V% b+ j          print "square number"
, }% z: ?! F; e. Z$ L( k4 n       else
2 s3 F' M- c# K! c7 g) h          print "no special number";
2 ]6 z3 V. ~+ I& g5 g          print "or number greater than 9";
4 g! I( n9 T1 ^, ^- J, d% W5 Q   end;6 |8 l$ n: C" \+ w" J9 T/ 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-3-27 14:40 , Processed in 0.015640 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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