设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8445|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
/ \7 n: a1 ~! k0 Q* M       Ci :integer; qi : integer. C* k# P0 g. ~
do ( K7 F+ I  i0 _3 W0 l" M' f
       inspect Ci2 J! X& Q/ Y! K  f7 I% Y3 l
when Ci>0 and Ci <=150 then ' M' h; c. \8 Q" b  y3 i
       print qi=1;; U% r3 m3 F) s
when Ci>151 and Ci<=500 then
, H9 P% p9 z0 J; `' H( f0 K       print qi=2;
7 @( U8 C! ]6 vwhen Ci>501 and Ci<=700 then5 P% p8 u( `/ X" p) _
       print qi=3;* M/ A4 ^6 e/ j. e1 B
when Ci>701 and Ci<=1000 then
$ B# O; R/ y2 |" k- A( Y       print qi=4;- q, K3 q( J( Z% [
when Ci>1001 and Ci<=2000 then
/ [% P: ]- ?2 B7 ]7 Q4 u, W       print qi=5;& I6 Z2 L- d1 a7 P; [' _! m& k" y% H
when Ci>2000 then
) w/ d8 v" j8 T( D6 `% n- D2 @       print qi=6+ y( ]# t: P: W- p& `2 a3 j! L
end;  z" Z4 A6 z  [9 ^+ H7 I$ T
end;
( a4 ]6 u. k& `8 ^5 i  M1 r- [6 ~. [: Q7 A
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
8 U# o3 o0 P, b6 N1 A- g2 a( V- G/ f2 s          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:' m( M! x9 ~3 F. |9 ]  ?5 |6 |  K& R
(number : integer)6 Y5 ~2 c# Z/ B" l
is4 |6 v$ s% x! w7 d8 y2 {- s
do  z7 i) v0 O, V: b
   inspect number
2 H! @9 r* a2 R+ Z* e       when 1 then + N! i# Q  \+ _! T+ U0 T/ S3 ]
          print "not a prime number"+ S9 V/ U7 n  V8 e6 h/ K
       when 2,5,7,3 then
& q% P* M" G0 n8 A. @' c          print "prime number"
1 b4 H' f" b8 g( _0 Z2 i       when 9,4 then : B1 w/ [. k3 R/ Q% A6 s
          print "square number"
5 S) d6 v7 n; W  I' u, ~) i       else- {" k2 ?: l& S1 z* ]: x: d
          print "no special number";4 U: L8 y3 G- k9 X! Q$ P
          print "or number greater than 9";
" y' a" q4 V# }/ D* `/ `   end;6 t7 c8 K, ~- h* d7 k7 [8 E
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-4-27 16:57 , Processed in 0.015181 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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