设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7649|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is$ `: V  j: |8 g6 C; Q9 `% ]' Z
       Ci :integer; qi : integer2 `0 P. ]. W2 a- O
do " M3 R) a3 T7 l0 t+ q. |* I# [
       inspect Ci  g# p4 s0 t' i9 x4 U8 z0 l
when Ci>0 and Ci <=150 then ! n  H2 p7 T6 e' u
       print qi=1;' \0 `. t( G% m% V
when Ci>151 and Ci<=500 then
* z, h) @4 U* F4 b, N. z- t" H       print qi=2;
7 c7 s5 A3 W' x' X" S9 jwhen Ci>501 and Ci<=700 then1 w- y0 F( m& a$ v; u% ^# ^% S' w
       print qi=3;
1 |2 t9 j1 d" h) B0 ~when Ci>701 and Ci<=1000 then
- D* s8 ?: m3 }, G       print qi=4;
5 \$ T" A" K3 H2 p2 E6 @, Dwhen Ci>1001 and Ci<=2000 then
: S0 [5 u+ B9 w       print qi=5;
0 d, o% x  t; `; a( Awhen Ci>2000 then
8 z! G. R" l& j8 a) L& F1 V       print qi=6- W+ ?. _  G2 |4 j/ a$ z4 b
end;
7 U7 R, X9 i! yend;) [2 K  }9 h, X3 I

1 _0 n3 e/ @7 B/ D- v0 V- \! B          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?$ N( r2 H8 z+ y
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
( ?8 ?9 t4 |+ o+ _. ~(number : integer)
" G4 M6 i& [2 }. g4 Lis
) I" Z/ E2 m6 F! t4 A! Wdo
/ i2 a2 K6 m$ h   inspect number
1 ~/ ?1 d5 [3 P9 V* E       when 1 then 3 h0 s& h) V; O# D2 c
          print "not a prime number"
/ Q  I* P- M4 H1 X% A       when 2,5,7,3 then
. m, Z% V% J8 M: g5 n8 V* f+ u7 G          print "prime number"/ g4 v, h5 z% S1 S4 X. N' B
       when 9,4 then : z+ z$ [  H: o6 ], ]3 T
          print "square number"1 a7 m/ C2 }  _, F; j
       else
, P9 [1 F: \9 w          print "no special number";1 L2 i+ H8 x( z5 M
          print "or number greater than 9";
' K- C% _) N% Y) N; V) l/ n   end;. I& c; A) L. X
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-12-23 11:59 , Processed in 0.013995 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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