设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7843|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is9 j2 _0 ]1 V) D3 ^6 u0 g' [
       Ci :integer; qi : integer
1 M3 |4 h' Z2 Q$ X" u, Ado   }5 o  I0 ]; S' E& L# |# S
       inspect Ci' G2 p7 a4 |* X# C  m. [
when Ci>0 and Ci <=150 then
: f' Z$ R; M& h, A* x       print qi=1;# [, t! J0 R/ V* z- C6 X
when Ci>151 and Ci<=500 then0 F. s9 D2 ]+ i- S0 M# Z
       print qi=2;' b0 D* g, V, ~  Q
when Ci>501 and Ci<=700 then& W5 d/ B' R* @' H
       print qi=3;! n- s. O7 |8 p/ Q
when Ci>701 and Ci<=1000 then" j0 z+ t* n" u6 D
       print qi=4;
' v( q4 Y' Z: c, D. a  Bwhen Ci>1001 and Ci<=2000 then3 S; R# k5 ?6 ^( `( }# B! W: \8 D
       print qi=5;
% U) `$ i! D1 R% Vwhen Ci>2000 then7 b: ?' I5 s) o* I6 w& U0 P2 Y
       print qi=66 s# \9 t2 _& T( @+ |" w
end;+ y' c- ^! f% v8 I$ P) z8 D# F; J0 r
end;
$ @) h) o/ {7 Z( M0 y* O% \
+ q, q" f/ u. u  q. j8 `! q% v' \$ m          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
4 X5 h+ B# _" t5 J/ V- S          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:/ t% F; L, i# H3 x5 r9 [4 q
(number : integer)% B6 k! u9 H. _7 B0 |
is8 Z" Q, _' V- h, A0 k3 r
do
! e% T* ?$ v4 E- X9 \, l   inspect number* g- P. g- z1 Q# Z- F. T! e
       when 1 then
4 z$ `7 y) H7 {' P0 d. j& n          print "not a prime number": Y; _6 B- J; B: ~3 Q1 N
       when 2,5,7,3 then
* U& ~, p5 f( V' E2 {0 G, f! T2 H          print "prime number"+ [: d5 b- z6 x$ C) x8 ]% i0 j3 X
       when 9,4 then & w) n: ?9 H8 I$ X3 b$ N. o
          print "square number"6 @! P) g* q: Q$ S8 U4 w  {) W
       else- t5 s1 U* U: ], w/ k- s
          print "no special number";
, t6 h5 O7 P" D7 S+ ?' P8 k! A7 B          print "or number greater than 9";
$ }; a( l! j( b- j   end;/ C8 X1 ?: b3 v3 {
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-2-2 19:51 , Processed in 0.015809 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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