设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6966|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is; t+ S3 u, M* Q, L2 S4 s
       Ci :integer; qi : integer
, E* l. p0 Q# o: J! ido ' ?8 T, [! M/ u; c# B; C
       inspect Ci
2 @: q3 M# h9 t) rwhen Ci>0 and Ci <=150 then + O+ d( A$ d3 L5 W4 p$ u  [
       print qi=1;
, u0 E3 n/ K- Q+ D$ T, T$ @3 Zwhen Ci>151 and Ci<=500 then3 V$ @! Q. J" D( r
       print qi=2;
2 [3 N2 t5 u+ J/ {when Ci>501 and Ci<=700 then9 a' q; d/ Z0 f- f- g/ N" f
       print qi=3;
: E) n" o" w" M& O1 K/ D( Y. u* owhen Ci>701 and Ci<=1000 then! s1 t2 e$ E8 z& P& P  Z7 B% _
       print qi=4;' x" W; v5 W9 ?8 G  x) q
when Ci>1001 and Ci<=2000 then
6 n6 U5 i& @# K; D       print qi=5;+ _. u( K8 B& c, U4 ?# z6 O
when Ci>2000 then
, H, e" E* s5 E/ G/ ~4 H/ a       print qi=6. n/ d9 |7 d7 }& u
end;
" Q1 ]8 _9 a. |3 hend;
$ X. S3 t$ {+ z  q5 P  w2 `* [& Z  ^1 R! O4 \) n
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?( P. N1 f2 r# x! d3 l5 U, L4 \
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
$ u( c7 p- s" ]7 M7 n(number : integer)
4 q: h, i, K7 ^8 b/ t2 E1 a% c/ kis
5 T) i( ?$ O4 d$ A( Z& ~* o$ Sdo
, g9 M9 F3 Q) k$ {3 [   inspect number9 @- y- U$ I" U( ~: e$ J
       when 1 then
! t) F" z8 `2 x( e5 I7 y& u          print "not a prime number"% j" p) N9 k; J$ a  t8 Q  q
       when 2,5,7,3 then
% F3 X# V& y% P$ _          print "prime number"5 L, q! K1 a) t. L$ z
       when 9,4 then
8 c6 V; g* J: u. ]) l          print "square number"' j2 B, l& q6 \; s' @) ~# s$ ^
       else
  S  D2 {. n3 E" d0 d) T          print "no special number";. O. V2 u$ `3 ^* z" i+ q' E3 m
          print "or number greater than 9";
; ^8 O' B: t; C% K( N- I5 q   end;; l/ D; `* L" ~: r' B. r/ u
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-9-18 06:31 , Processed in 0.115773 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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