设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8489|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is/ C9 i! D% X' }! A" z; J' o
       Ci :integer; qi : integer
  @, G4 E5 k, f5 \2 xdo
% W4 ~& q9 B0 I- V       inspect Ci
( G) l( w% O" [' k& M$ Nwhen Ci>0 and Ci <=150 then . D: g4 ^( ?6 N" {; Z+ j
       print qi=1;
1 Z# K, ]  N, v% @1 Bwhen Ci>151 and Ci<=500 then) w4 C! U9 `6 {" a" x
       print qi=2;3 e& z3 W7 ~# i4 {  R
when Ci>501 and Ci<=700 then
. W$ _6 Y: G, T& T$ m       print qi=3;
- q' P8 C5 ~( a) U9 f8 {when Ci>701 and Ci<=1000 then
* ~: A6 V, M$ l- u4 E8 ?6 b       print qi=4;
1 ~; H2 G( J0 ]. G7 ^* T8 e6 qwhen Ci>1001 and Ci<=2000 then( B; s* S  G8 n$ G
       print qi=5;  g6 t' ^" o* F  c, D" u
when Ci>2000 then
( t8 L* h% j& d. V% M! @       print qi=62 i7 j" W! i9 b
end;: h9 h3 s' D5 B  T
end;$ ~0 z3 z) ?8 z& ?5 n7 e

* u/ r+ C0 R+ ?# ]7 Z          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?* A6 t. X. L% d* Y# H
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:7 n$ d" f" s; p0 v: C' a. \0 A: z% ^
(number : integer)
6 Q9 W0 v' s) }+ \4 r0 x$ w- N5 yis
1 {  U" I1 E6 Rdo9 b# h- ?& |( ^
   inspect number
# }* X0 g8 Z% O) N) h       when 1 then
) L; K4 X9 `3 X: u7 B- g          print "not a prime number"+ S1 H/ G2 l7 s! g8 E2 K- B( }
       when 2,5,7,3 then
2 J) P! C) j; h, `2 B6 o% l          print "prime number"4 G7 Y6 L. Y3 q
       when 9,4 then
7 Y. |5 h6 h: `& s          print "square number"
( H9 w$ e, i$ {  W       else
" w- _/ B( c2 ^& v3 o2 [" X          print "no special number";
; q7 u9 D$ \) l3 E          print "or number greater than 9";
5 \+ u) ~& N4 q+ V5 N3 u2 j   end;( j' A+ Y: }& y8 N9 K
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-5-2 04:05 , Processed in 0.024227 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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