设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7516|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
+ t. y& |- S* z" J( U       Ci :integer; qi : integer
9 A0 l& J# f, u( [- o+ `, Rdo
; c7 c5 `$ q* G9 ]3 G( q       inspect Ci
3 g0 z1 Q/ J  W, q" Pwhen Ci>0 and Ci <=150 then
5 U, H) L' T% ?3 r  @- q0 F  b       print qi=1;; C5 e8 F& b; c' r& o+ a# i
when Ci>151 and Ci<=500 then1 z0 r' M! y1 y; S" k4 d
       print qi=2;
) p+ Y5 }5 @5 v  o! T4 G+ Pwhen Ci>501 and Ci<=700 then
. T3 H6 X6 s2 p) e       print qi=3;
5 {, z, @  N2 C) Z0 H# e+ }9 pwhen Ci>701 and Ci<=1000 then
6 q4 ?9 H; @6 O5 s2 l       print qi=4;
+ h6 ?+ H" U7 ?- ]when Ci>1001 and Ci<=2000 then. s+ w% Z  L) d6 S  C: E/ X9 h
       print qi=5;6 Z6 {" j1 l$ _% q  g) c
when Ci>2000 then
7 D! J4 C! {  @, S7 b       print qi=62 \. V; `4 }/ |) _2 J
end;
$ J1 {7 l1 ~9 \  wend;
; ?& @$ X( y, K6 r! x* z
( H) t$ R: O8 `; b. y; Z          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?" q' I: i3 @1 C9 B0 a. w
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:4 @7 `- i( X/ H- @$ L( y/ z
(number : integer)$ g' j: k' z4 J$ N  c. `. {
is% b9 i( L! v' H) l( h9 @# Q
do0 d' r+ J( w+ V; H9 I
   inspect number
$ Q# |4 W0 g+ s       when 1 then 0 p+ y8 q) x8 U" f* ~+ I
          print "not a prime number"
0 m- t( L, U9 x       when 2,5,7,3 then
. t" B' C" i( Y. D5 s5 D7 k          print "prime number"6 Z' `! a" s  H* j
       when 9,4 then " L* n0 v7 p3 S" p4 F/ y( U
          print "square number"
/ y% L0 E3 H/ N7 W, z1 _       else6 }; G2 o, O6 n
          print "no special number";
; j. O1 f+ B) ]  |5 z  ^          print "or number greater than 9";6 H9 V6 E  o! R0 f6 N
   end;
. n+ n9 x0 L& m/ c& G8 aend;
 楼主| 发表于 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-7 13:14 , Processed in 0.050408 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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