设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7501|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
$ w* Y2 @3 o0 {" A  t6 V- |2 q       Ci :integer; qi : integer$ u2 T" T0 W5 W: g1 B
do 4 L0 d7 Q) l" v( F9 j! V0 v6 {
       inspect Ci
7 n" l6 e: F  `2 a* k2 r! mwhen Ci>0 and Ci <=150 then * `( o* ^: J# l. M- |$ k
       print qi=1;- ]1 m" h  R! y4 o2 ?3 V$ O
when Ci>151 and Ci<=500 then
! K: P% E4 |1 m. W9 R" q' X       print qi=2;
; d/ H1 b6 g1 Bwhen Ci>501 and Ci<=700 then
+ \8 j8 U$ R; w" d0 r! o6 V       print qi=3;7 J- X. V9 ^: ?
when Ci>701 and Ci<=1000 then$ R0 w. B9 L: p& g  M- A
       print qi=4;
$ Q. K% R: G- j( r( g) v' Gwhen Ci>1001 and Ci<=2000 then
4 q0 G6 I+ ^8 Y1 F& @5 V. R1 c' ?       print qi=5;' S# K/ ]8 r7 w5 ]9 o' E
when Ci>2000 then
0 ^3 W6 L) V* i1 @       print qi=6
3 M3 X# u3 Q; i1 }' X0 u/ cend;
& T" z6 ]5 N# y. _- `& {% Gend;
5 K- U9 T  y' m9 k$ n" [
5 k$ g1 S: I3 C4 K' z3 K! B+ {          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?: L1 g- P, T' z, N
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
; c- \+ Z3 f8 X4 ^(number : integer)
/ @# K* a6 a) L- A# v$ L+ cis( q4 n4 v4 g) g: E+ s
do+ o0 B7 ]2 N7 @7 s% j
   inspect number# F! Z6 V2 t2 T/ B) w
       when 1 then
7 Y3 x, C+ n# ?: R6 H0 W, Z          print "not a prime number"
- B" g% b+ }1 x3 [( [/ j7 }3 k5 A       when 2,5,7,3 then
$ {! U7 K/ t2 I8 ^+ O+ Y          print "prime number"6 P' d8 C( P5 r: ?2 Q/ V5 ~# K$ y
       when 9,4 then : V& j% Z1 t; \; d
          print "square number"
: n) p5 N; V% k( _" q3 b       else& d* m3 Y6 l& S$ I. m8 I2 B, K
          print "no special number";  E0 i% h" I/ A1 D
          print "or number greater than 9";
0 Z' N9 S* p# u! i6 E& q  M   end;; |8 m' x  q3 R3 Q% m, V) w
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-6 06:11 , Processed in 0.012775 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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