设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9051|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
8 M$ d* Z/ \1 P& F       Ci :integer; qi : integer
: d. q% N+ [  }" l. H' f4 Odo
2 }& P8 y+ b$ U) O! {' v* W       inspect Ci- i( d4 p5 x0 v- ]% ?
when Ci>0 and Ci <=150 then
( C# s+ r$ W' g; v+ J       print qi=1;
8 R$ g( ]& P6 b% ~5 K7 P& ewhen Ci>151 and Ci<=500 then- o7 q% \3 H6 K' j1 e1 O
       print qi=2;& n+ n) E# X+ I
when Ci>501 and Ci<=700 then/ K5 N; V# v# v& j* ^
       print qi=3;
% q9 I) Q# x4 ?6 U0 _8 nwhen Ci>701 and Ci<=1000 then
4 l1 H& f# c4 q/ k  D% y1 D6 j       print qi=4;
9 i3 ^! ]" h* ^+ V6 t" Twhen Ci>1001 and Ci<=2000 then
; [6 a! t: f1 i- u8 v       print qi=5;& p6 O7 g. P/ W# D" M
when Ci>2000 then  v) Z# W& o3 w9 Y
       print qi=6! x/ x  _& u, K4 h% m
end;
  _: n- q, C1 ]5 f/ xend;
- O2 u6 b3 X  l! b% ?) l
, I- r' q2 u/ e' M          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
3 H- W8 D! l" N4 |. k8 o1 T          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:; F" `. O* T4 n/ E, J! V. f! V. Y. F
(number : integer)
3 b1 v) Q9 ?& i* qis  `1 D: ]9 K* ?" z
do) r- A5 r  s9 D
   inspect number
( V2 n1 b$ A7 {& t; X: ]. R2 k/ ]       when 1 then 9 z4 D1 Q0 D# L* U) p2 {
          print "not a prime number"' K  e. U9 n& Z$ e
       when 2,5,7,3 then ; r$ [" _+ G6 h! d1 v4 B) H, Y
          print "prime number"
# E+ z* o8 @# v       when 9,4 then # S1 J1 ]# W, r# S1 n3 Z
          print "square number"$ Q  t6 i9 A3 p7 ]% Q
       else- @$ |: `( W, Q9 w* y; t; H, s
          print "no special number";1 z/ ?/ u1 |4 N. B, [! U
          print "or number greater than 9";
7 h3 ^& o6 `2 H  G. }. [   end;4 f/ \' W, V2 {' E+ \; ?5 ]
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-7-26 20:15 , Processed in 0.019055 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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