设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8469|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
( W' g. W  U# L( V4 k% N* L       Ci :integer; qi : integer* F$ p2 W. b3 i( W. R0 }
do
% ?- }! h+ [# B+ r7 e9 D7 I4 f       inspect Ci/ ^% h" H) j3 y8 K
when Ci>0 and Ci <=150 then # o3 f  g5 l3 X$ e$ H4 q6 e
       print qi=1;& a6 u5 J1 n3 n9 p* x) U' v* b) u
when Ci>151 and Ci<=500 then( z( `, U  N4 v8 D$ O$ }' @  C0 V# ~7 D
       print qi=2;" o4 ^7 }$ R/ ^- K0 _3 r8 N6 h
when Ci>501 and Ci<=700 then3 ~; g: v7 ~& R! k
       print qi=3;6 O; R: Q6 k1 x) ~/ C+ ^
when Ci>701 and Ci<=1000 then# F9 B: f8 w% v% |4 H6 O
       print qi=4;
* a) m5 X3 f1 {when Ci>1001 and Ci<=2000 then4 P7 }" t! i' n( ~5 u7 y
       print qi=5;
+ v; e1 H1 B! `( d9 C+ wwhen Ci>2000 then& U. {6 I# y/ E0 I
       print qi=6/ b- R! f+ v  a7 N
end;
. R+ Z0 q' m5 ~1 Vend;
, y1 |" }/ k6 D. C4 w+ o1 t0 Z, V$ {: }# C
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
# N( e* B1 R$ p& `0 O" l; o          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:2 P$ R# N5 i; U" X0 \3 ~: E
(number : integer)
* X) g# P0 r% p! S0 a( vis
4 z8 Z3 E4 G1 v: ]( wdo2 e- V! B2 n" l
   inspect number3 C9 w: Z3 v1 D: x) \
       when 1 then
+ B( p: `4 |1 b5 K          print "not a prime number"
' Q8 r# d: T* y1 H+ q       when 2,5,7,3 then
& a2 ?7 n2 p, f7 s" {8 f          print "prime number"
+ o0 _4 t3 |4 Y3 O3 D       when 9,4 then 6 B! T' X' a) r: M+ z
          print "square number"" i' @1 M7 Q; |- V1 L
       else
; ]% N5 q0 F9 Z6 g8 j/ C          print "no special number";
5 ]% |( |( q6 n8 m' B          print "or number greater than 9";
7 x  c( }8 R- Y   end;8 i" v7 j$ t, K: l$ k  e
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-4-29 16:06 , Processed in 0.016407 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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