设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4605|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is: J+ h  d1 |' _+ Z; a5 S4 b# z/ C
       Ci :integer; qi : integer
$ {$ X3 ~4 n; r5 ldo ) K: s, R( ]" [& E6 g" q- b
       inspect Ci
& B' N" V( d1 m# B: Iwhen Ci>0 and Ci <=150 then
: u4 J( w6 W2 g# h' O7 N       print qi=1;
( B( k% P1 M2 ~0 c! n3 qwhen Ci>151 and Ci<=500 then  t8 A) \# ]( k! z
       print qi=2;
2 h. M: z- q( M2 ^, L% H* Z, T( U# owhen Ci>501 and Ci<=700 then
+ H  c: p- J% p9 f% ^1 l$ Q3 ?  N       print qi=3;
# E& n( H; D5 v, cwhen Ci>701 and Ci<=1000 then/ I; G9 r( C  H' d6 D
       print qi=4;  O7 y0 K3 s2 T+ o" T* {1 O
when Ci>1001 and Ci<=2000 then: A8 N2 S) @1 _. j5 U* }
       print qi=5;. y$ n' j6 U! q! t! Z, x( e
when Ci>2000 then
& p  c' R: V5 ~" y       print qi=6
4 k( Y* V2 O* g! J" o1 G$ R9 d3 `$ \: `end;
8 _+ j" _6 o4 g. I( m& dend;7 M8 d/ k. c  x8 Q" P) n, d

1 \. f0 P0 \- G# x2 f          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?  r2 h' c4 A% _' n" ?
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
$ y: S3 H& H9 i& f0 l# g(number : integer)% f& _3 n! Q/ z8 A6 A1 j
is
0 y0 E, k( B% |3 w; bdo
6 G- C- m. f7 Y( }. u' Y   inspect number% z9 F: H' D7 l' Z3 g- D0 H9 a% j
       when 1 then
5 R2 q. H/ C5 W( g$ a+ {* Y; a" Z: G          print "not a prime number"
9 ]# u- \7 B$ k0 X& q       when 2,5,7,3 then
9 e: N! \. Y7 n; k          print "prime number"
2 B, K) x6 J& ^1 z! T$ I0 e, a       when 9,4 then 0 x; Z9 J4 `) B( c
          print "square number"
& j: q( D0 C8 H* V9 v4 Z& q       else& f+ R1 Q0 K2 W# Z6 w4 i
          print "no special number";
2 b0 ^8 O' x3 L& U          print "or number greater than 9";
* C- T" u5 C# m% b' u' W' m   end;
/ [7 Z9 L0 ?, b% q! ?1 Jend;
 楼主| 发表于 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, 2024-6-10 01:22 , Processed in 0.010230 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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