设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9334|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is3 d% }, B5 [6 H& ?1 U) l+ j
       Ci :integer; qi : integer
/ y. n6 p5 b5 N7 i( m" Ddo
1 m' Y8 O. N  n# b6 a       inspect Ci
1 k' b, ^2 R  V* iwhen Ci>0 and Ci <=150 then
+ W) P' v6 |: {# k+ F! q! O# }       print qi=1;% a$ {3 L6 v" j% G$ B6 z( n7 _
when Ci>151 and Ci<=500 then
( T6 J$ t* ]; D       print qi=2;8 k. ~- u' ~* @& W' |
when Ci>501 and Ci<=700 then
& i7 c4 Y2 {  T/ r, _  j) ~$ _       print qi=3;/ G. S, P. r7 x/ q! Z
when Ci>701 and Ci<=1000 then
- C( ^+ P0 F; A( P0 J" o0 G) P5 d       print qi=4;: S" w0 q+ J5 h
when Ci>1001 and Ci<=2000 then  b0 _% ~1 f% W1 }+ v) P
       print qi=5;
- }) h& M( J4 vwhen Ci>2000 then1 \; u1 D7 u# o
       print qi=6/ C' n# x" r( S" X
end;. z! U' a' b5 R- ~) `+ @$ J5 S: [+ U
end;
4 F1 t" R3 @' W1 B2 J& ~# z3 F6 N2 @" U2 X5 P" l
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
* Z! X4 M& f7 L. X# S: {( P1 n6 i: i          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
  x8 J7 w/ ~" j$ d(number : integer)
3 k0 g# [* z' X- f, ~is  r9 G) K( ?) M+ i, ^6 A
do2 ^9 y4 }3 e3 Y: z) B0 `+ L
   inspect number
( s/ X1 ~: F) f" b- X. ]8 f9 i       when 1 then : L) i# P7 ~( Z
          print "not a prime number"
: x9 R6 a! L& B8 a- E0 s8 g       when 2,5,7,3 then ; D% d( t1 N8 b' B3 }! c! C
          print "prime number"& N- d6 x! h6 Y* m3 |0 S
       when 9,4 then
1 i. M: u& F7 {  T' W6 I! V, W          print "square number"- _4 U3 D: L- w0 c4 z/ v  W; w
       else
2 Q5 w$ ^( M9 l- T% d' W: n) y          print "no special number";
; d, Q! h: c# }! q1 q          print "or number greater than 9";0 ]9 w" p' L5 K1 ?; b, E6 @
   end;" M, j( U' C7 m3 T" n
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, 2026-9-2 09:04 , Processed in 0.021952 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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