设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6925|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
' O: z& O9 D0 S       Ci :integer; qi : integer
: ~3 N0 Q5 U; W# T( m! r, Odo ; ?6 ~& p% b; p- e. d* ]( b8 [
       inspect Ci
1 P$ o! G+ V7 l* X- N4 o7 e2 twhen Ci>0 and Ci <=150 then 0 \* h$ f# G  j' |' `7 j
       print qi=1;
/ o8 R$ n  z1 z+ W* X+ e1 gwhen Ci>151 and Ci<=500 then
" b9 K8 i" \% _" Q. A# Q       print qi=2;3 k7 }0 N) H! j0 a
when Ci>501 and Ci<=700 then2 Z4 G3 b6 h7 U& i
       print qi=3;
9 b0 x- n4 s' hwhen Ci>701 and Ci<=1000 then
: Q9 [, m8 ]1 J6 Y( C, q       print qi=4;
5 |, Z8 z' k4 o2 N- |when Ci>1001 and Ci<=2000 then& e/ u' e- Y9 o) U2 p9 U
       print qi=5;3 J2 a" \; G2 H0 g9 s( \, [& T0 a
when Ci>2000 then+ T: Z; }; S) J9 j
       print qi=6
: K5 S5 A- l4 Q6 T" mend;4 r  n* `9 ?" j4 v
end;9 O, w- x( E7 J# ~6 F2 I

- I1 g7 ~  Z9 A! e9 a1 l5 Q          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?' O5 o0 l+ `& M; R6 I+ K. o# L
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
1 P# J6 ?! Q( k5 s" ]6 n(number : integer): F( [: W" Y- I; E
is
+ `/ o* n" [; d( p( T$ F1 W! q4 `do3 z9 i- W# M! o7 A) U
   inspect number% |4 o8 S2 O  l5 y" Y" f0 Y% Z( ]4 _
       when 1 then
1 c6 ~+ G7 C& i8 B2 A, C4 j; ~# c          print "not a prime number"0 ^1 r8 K  x# Y& W  R% N4 o9 u
       when 2,5,7,3 then
* n7 E4 n! X! u: C( N3 Q          print "prime number"% C5 D6 q  ~: t1 n* f, f1 t1 E
       when 9,4 then
  v# v6 F5 n2 F( r- \0 Y- p1 `          print "square number"
8 i" O) `$ p( u* ?" W& j4 a       else
! f  P4 R, I; a  K& n6 W4 `2 G- {          print "no special number";/ K0 `5 f* c9 P# O+ d
          print "or number greater than 9";
" L7 i8 [  D  c& [" Z   end;+ @8 G) n  w, j' [# Q1 p  s
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, 2025-9-14 04:27 , Processed in 0.023911 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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