设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9189|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
' L% j" d8 r) A4 c1 t       Ci :integer; qi : integer
" f. n  D) I1 s, ldo   L% d  {' b5 }5 }) r
       inspect Ci$ d" Z' Q7 J. ?" |# }
when Ci>0 and Ci <=150 then
8 P& H6 o+ `0 q, T) e       print qi=1;+ n3 K, F$ i7 U/ o: L6 \
when Ci>151 and Ci<=500 then
% t9 t+ W- l0 T: p& M       print qi=2;9 z; [+ x. h$ Z* o% |8 I! ?; R9 F- _
when Ci>501 and Ci<=700 then- T) c/ k0 H  q7 Y
       print qi=3;
1 c0 [, u! Z! a" nwhen Ci>701 and Ci<=1000 then
* a( b  M! u8 ]1 P; G* Z" l; ~       print qi=4;- j1 Q" F" \% L4 Y- T
when Ci>1001 and Ci<=2000 then
$ y) Q( r  B* J$ W+ d( I/ V0 R; X; D       print qi=5;2 _7 Q4 l  L3 N9 J/ @- d
when Ci>2000 then8 v$ ~" i2 s; g- Y7 P2 Z
       print qi=6
  O$ h9 r" S/ y* M4 C) x# g- xend;8 S1 i; |) e( m+ d9 M+ P) k' U8 G
end;
0 l9 ?. ~. [3 e: u) L% x% J6 e7 t5 O
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
7 P2 z" c& S9 v% h8 A          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:3 z% t1 r0 D$ y- x3 x2 o. [" H
(number : integer)/ }+ M, I! _. ^6 Y/ v
is4 `# p9 k, K' L5 X! ?2 k: I
do6 S) c; P5 e# ?) @8 }
   inspect number/ j9 q4 X( C: w$ b
       when 1 then / \/ A% D0 i; a0 U, _3 u. N4 I
          print "not a prime number"
* g" C( W# Y6 i0 ^. ]$ Z       when 2,5,7,3 then & i* f/ a8 q7 b5 @0 q1 O$ P0 K
          print "prime number"0 I1 k. M* e( D5 S, }, d! q
       when 9,4 then
" k% o4 p' K. H3 p          print "square number") V* B  k4 K! h. }/ N
       else
# m. k/ L; S/ H# X, G1 |. p1 f! V          print "no special number";
7 a9 t& N8 K& ?! `! x          print "or number greater than 9";
$ w; ]' P$ {9 O2 c- Y/ I; u7 S4 u   end;
* N3 L' ?1 x/ A( y; X, l/ ~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-8-9 05:58 , Processed in 0.015457 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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