设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7537|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is3 h6 T  {7 y8 d6 _# e1 |/ T
       Ci :integer; qi : integer
  }9 y# R7 n, |9 L  {do - w# @' C- K+ z  Z9 D$ b- k
       inspect Ci
2 v0 z2 z9 T6 @5 ^6 ]5 P) kwhen Ci>0 and Ci <=150 then
) ^9 U9 F) C+ s* W, t) I       print qi=1;5 K% T7 p( d- U, h  U8 @
when Ci>151 and Ci<=500 then" ?, q/ A3 d' z
       print qi=2;
' `) E# ]8 v% q5 D% V: ywhen Ci>501 and Ci<=700 then7 |# c1 A9 c2 @3 q' g
       print qi=3;$ ~4 d! N, w. p
when Ci>701 and Ci<=1000 then
  m5 m- ^: w% X! v9 m; V       print qi=4;
2 Y' W' n+ F( o! _9 Ewhen Ci>1001 and Ci<=2000 then
- w6 C/ j& j5 Q; h2 F       print qi=5;
; C8 ^  I1 |: p. _) l8 ^3 vwhen Ci>2000 then
* y: x7 ^8 _' K       print qi=6
! Y2 @% c' C4 n; d  K. d0 t$ l8 Zend;9 H! p& k- Z2 [% B4 C- H2 m( S" E
end;5 z0 \+ L) I5 w8 ?  s2 u5 e2 b

" e+ ^6 `; \) g+ B$ C) |$ E5 i6 [6 a          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
% X  s. y* Z) `0 h# P( K          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:0 B2 y7 Q  |! x' U% M: Z  f# l
(number : integer)
: E4 z; _6 V" h9 M  b  Z  Yis! g+ e6 K& q6 `& J7 B! N
do/ @0 P, z0 C- J8 e$ {
   inspect number
$ O+ x0 s0 e( ?       when 1 then
- a) b0 r7 B2 N          print "not a prime number"
; l  R+ ?$ {6 k% m' N2 d       when 2,5,7,3 then
0 A' o7 A2 a0 l4 y          print "prime number"  u! B  r/ F0 W% c, H3 p$ _
       when 9,4 then 3 j- O$ ~7 F  g
          print "square number"5 t9 M) |/ ^0 R3 x' W
       else  E3 [+ p  l& V0 a( ^7 {
          print "no special number";
5 B9 q' P" Z* v2 `/ ~0 p6 T6 g          print "or number greater than 9";
8 a/ L+ V0 @, T   end;
/ J+ o: T" n% ?* qend;
 楼主| 发表于 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-11 15:22 , Processed in 0.015069 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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