设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7818|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is+ c/ X- _; |9 y# ?, Y3 ?
       Ci :integer; qi : integer
8 k9 r/ I1 U2 n' C  i9 d. i" Ddo
3 S# W& I, N, O1 L       inspect Ci
6 ?; a+ W" C* S, k8 a6 Gwhen Ci>0 and Ci <=150 then 0 w% N1 z* a9 N+ n( `
       print qi=1;
; |' Y* r% K$ g0 \% Rwhen Ci>151 and Ci<=500 then" ?1 n. A8 G7 S! S
       print qi=2;& e' K6 R' d7 s  A* z
when Ci>501 and Ci<=700 then5 X4 ?" A0 X0 q8 E
       print qi=3;
2 U6 M0 R# r9 K4 y9 X" ]) I" uwhen Ci>701 and Ci<=1000 then% g- }. v8 d: }1 y8 X9 U- r" X
       print qi=4;% z* H) I7 ?/ Z7 {% d) o
when Ci>1001 and Ci<=2000 then  }7 w  s, R1 c" h9 r& x  A
       print qi=5;) S6 x: z/ j, A  r0 p
when Ci>2000 then5 F3 R8 e, V  c7 b8 V
       print qi=6) R! Y7 v7 D6 \
end;( u6 P0 k& P7 q, y
end;, i) G; [& D/ n0 ?& p7 T% f

8 r+ y5 C" b, f. [/ r) s          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?* }; p  ?- B# J; Z
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:. m" k. I, n- N  ~6 h4 N
(number : integer): e7 p  L) }/ w; a: d
is- }  T2 O; ^. ]  I. Y- M
do/ x7 S. A8 _2 i' g
   inspect number& x# y8 _8 S& [$ M* R" p7 R
       when 1 then
" j& U% C9 v6 y; B          print "not a prime number"
0 W: ^6 M  N3 a# |0 c       when 2,5,7,3 then
& Q" O3 A6 A" k6 ^" \# g          print "prime number"+ V! E% T. V! r4 T4 @
       when 9,4 then 1 t! X' k4 y* v  E$ ~
          print "square number"
& ]8 H1 N2 d) t, ]5 n; w; s       else
3 C  C( _  v2 y4 Q1 m( w. w, |          print "no special number";
1 q: G0 B' x& [" ~2 e          print "or number greater than 9";# E% P* p, S6 G8 Z7 T. S5 l1 k' L
   end;
# [$ N' i# ^$ a5 P3 o( Tend;
 楼主| 发表于 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-1-29 16:30 , Processed in 0.015929 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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