设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7552|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
3 H) o# }3 E$ ?4 f, S5 }       Ci :integer; qi : integer
, }( Z5 \; @1 [6 h# T; J+ Udo
& A, x2 _, n7 c( y0 e       inspect Ci; L; v5 k4 h7 |  {9 c/ N
when Ci>0 and Ci <=150 then # t( R3 u+ s4 h. |, b2 @
       print qi=1;8 q5 z" [$ L0 l1 G1 e! m: w8 C% n0 M2 w
when Ci>151 and Ci<=500 then
& [' J) _1 S* a( S. w; u7 u+ [5 M3 K       print qi=2;; T: v8 ~% @7 @* \
when Ci>501 and Ci<=700 then
/ E; s7 X0 ^2 s5 y       print qi=3;
- @! U% t, Q% D' ^- Kwhen Ci>701 and Ci<=1000 then5 |2 Q. |& y# h7 I8 p  o3 r: P
       print qi=4;! T9 X) a( w4 @
when Ci>1001 and Ci<=2000 then; {- A, ?5 Z; u* ~7 i+ j# e7 Q
       print qi=5;% h! o# ~" I1 ?1 x, [  ^. H5 @1 n  Q
when Ci>2000 then
2 {2 x& {5 z2 D       print qi=6
+ Y# n- g7 l" b- ]end;
' h) [& G: U, I# uend;& \& O' q# t* a3 E, r/ `9 b1 f

: J6 r8 {  ^3 `; ^" w% z8 O: c          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
5 Y' v& ]8 A$ `4 n          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
& t1 Z% l3 c( U- |, A; ^. x$ Z(number : integer)
. f& Q7 s$ R, P8 Y' }) g8 J7 r1 \6 Lis
+ t7 a" Q+ w& z; z( N. }* v6 bdo
3 K: B  n4 \) E9 j! a   inspect number9 s& {& i* [2 n4 N8 \- n
       when 1 then
  B0 U0 c* h, J* h! N2 g          print "not a prime number"
7 o" V' @9 |0 }1 y$ W       when 2,5,7,3 then & M- T0 |* m, r6 I
          print "prime number"1 B) m  K/ S$ }; [
       when 9,4 then & A  s' \) o7 a
          print "square number"
) `* Y9 Y: B; r6 b9 [       else9 e( j' X5 `" R+ Q% B5 q) l* T
          print "no special number";  K1 K. N% J+ }
          print "or number greater than 9";
2 x$ e' H) p  X: |0 E- R+ ]3 ~) b* n( e   end;
+ l1 |6 k: M" g  p4 T3 ~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-14 00:00 , Processed in 0.015860 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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