设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8024|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is, [: ^3 }8 Q2 `2 W& {5 F3 F
       Ci :integer; qi : integer/ ]& W2 X$ |0 n- b2 i1 N$ ^% D
do : ~% l, L) f' }, u# Y/ H  |6 P
       inspect Ci8 D* F+ m/ C2 Q/ C, s' B
when Ci>0 and Ci <=150 then
; C1 L/ r: T  r7 ^* S# J       print qi=1;
1 W" K4 z# L+ V* d8 c" A" gwhen Ci>151 and Ci<=500 then# {' \$ M! Q$ a
       print qi=2;% |1 k9 x3 t$ f5 H+ g
when Ci>501 and Ci<=700 then
+ J4 |/ X& E# ]( A: ^1 V       print qi=3;6 U! a4 {; N3 Q
when Ci>701 and Ci<=1000 then- K5 Q  v# V  t) L+ h
       print qi=4;% p) A, n6 P+ B9 Q
when Ci>1001 and Ci<=2000 then  D; B+ ?3 ?! D0 T6 |
       print qi=5;
: |: j: W) ~" O5 Mwhen Ci>2000 then9 @2 S1 C. J4 ?, N% `* l6 z
       print qi=68 U, j  i6 O% I" |5 u$ R
end;
% `3 w/ `* L$ Jend;* T2 w. D0 L2 j" l/ h/ P

. O$ b$ F3 e  J3 C+ a          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?& ^5 `6 \& N, p  h' }5 o) a
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:7 O2 n2 C- A  z" M) ~* C
(number : integer)! k7 g0 q$ D; N1 ^
is
& F# j& M0 _3 R; I) c7 i5 ^do
; ~. D6 O4 o1 t9 e# U   inspect number
; W9 ]% y: b2 ]5 k       when 1 then ' b$ Z$ `# {* j* H, W/ Y
          print "not a prime number"
3 L# W9 m' I' Q' O0 ^7 j       when 2,5,7,3 then - u! G$ c+ d% i) U5 S
          print "prime number"
' k  f! N1 P% G+ z6 Q       when 9,4 then
9 a; {6 U3 ]& \) g          print "square number"
' K4 X, u2 E& h" i3 @9 ^2 c       else
9 L% B) M  m; c$ f          print "no special number";3 W& _" A2 K! P# T. J/ a
          print "or number greater than 9";! b: I, z. c) H! L8 Z3 V- M
   end;0 N* e& b" r5 X* \; j; k. _
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-3-5 23:02 , Processed in 0.014160 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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