设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8537|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is7 u9 v8 \0 A" M, Z9 R
       Ci :integer; qi : integer
0 b$ R) {, E* ]( R, `" m1 Odo
7 {$ M, X' u3 R% i+ w& X       inspect Ci
" {* k! K) a0 s* q; h( X' dwhen Ci>0 and Ci <=150 then 6 ]2 G1 m0 t0 ^, P% o+ L/ x
       print qi=1;
0 b  L: C7 t) H# Ewhen Ci>151 and Ci<=500 then
7 D3 X  }1 G) u0 Z4 O       print qi=2;4 L* ^2 N% X' |4 B$ A( }& L0 f
when Ci>501 and Ci<=700 then3 f! K! i: u* Q
       print qi=3;5 \6 k' ^! j. `) K
when Ci>701 and Ci<=1000 then. u6 @% M5 `* l
       print qi=4;
9 }) x! L4 o' v! w' c4 kwhen Ci>1001 and Ci<=2000 then/ e& x5 b+ T( P& O
       print qi=5;  r$ Y7 l# h! K7 m
when Ci>2000 then# d' y' B0 k) U. b1 [2 V0 e$ l
       print qi=6
6 @  g& E, _# W* R( h) Cend;
- Z% @5 C- Y( \end;9 P0 H( T. i3 d  D: p

" M1 a$ c4 C, }  e6 A, Q          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
9 V8 n- s6 Y, A6 h          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
7 b6 ?9 y. l; J% y(number : integer)/ G+ Y' n: ?! {7 B' W3 s
is
3 K6 Z& a3 |  J! O0 x! ddo, U- U0 Z7 S9 m* ~
   inspect number3 Y3 C9 @" _& r+ x9 J
       when 1 then ! W3 v5 |0 z! l
          print "not a prime number"# ]  a( v5 V* R! l6 t8 X
       when 2,5,7,3 then * u" q/ `5 S5 {! R% q% c( i+ Q
          print "prime number"7 |" W) D) J/ q% {  d
       when 9,4 then % ]+ w; u7 I# n7 }) w% Q  t
          print "square number"% P7 e( q) R) f% i! k( |
       else
+ J7 p8 u6 W6 g) a- ^: b          print "no special number";
8 i! f$ L; v# D+ s          print "or number greater than 9";
! n& `; l# ?9 u" w   end;
  r0 ]5 u& x4 U2 H4 Pend;
 楼主| 发表于 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-5-6 14:23 , Processed in 0.019858 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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