设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8048|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is  f% `- d& E% n
       Ci :integer; qi : integer
! ~8 w5 F; Z6 L% H- E; ^% a; cdo ) @1 P8 q* n" |. S9 D- O
       inspect Ci& W9 L! W* R; I9 C$ k6 j7 @
when Ci>0 and Ci <=150 then 8 q; S! u0 O) g0 |/ V
       print qi=1;8 V  Q' B$ m& ]/ @# z6 B+ m
when Ci>151 and Ci<=500 then* L: e3 f5 X% V! w- \  X
       print qi=2;
/ B# }* j2 J( kwhen Ci>501 and Ci<=700 then; C9 m9 I: G$ m5 O
       print qi=3;
% y5 a! Q* n% J0 ywhen Ci>701 and Ci<=1000 then% u. P$ d- `& S" a, W5 w1 Q
       print qi=4;7 I7 P8 f& i# R
when Ci>1001 and Ci<=2000 then
" ~1 w! K$ @/ [, `2 p$ V3 D' X3 s       print qi=5;& L! N) i$ X3 F$ r6 M
when Ci>2000 then
! x) ^# Y5 ]" b7 E" w9 `7 F       print qi=6
  E$ e) S: l9 J, nend;  ~/ i& a5 n6 Z! M/ j& d; v
end;
' x) e# \5 t: i! t
3 N3 b; f9 u7 m5 o          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
" i7 F1 v* p5 V* P7 E( a. H          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:5 I. ^" S$ S  T/ c  }$ N
(number : integer)
, d. Q9 W" [1 }is. a/ D" d1 A7 F3 }. g5 A
do8 R7 d# J. {( ?# @) w: i( S% @
   inspect number
8 U6 L- O* V6 z1 j" ?4 y4 o/ E& k       when 1 then
6 u1 Y7 d& G- [: d4 [          print "not a prime number"
/ K3 S4 E! M5 Q  P& n       when 2,5,7,3 then
1 a: P. C0 o5 ~; O          print "prime number"
' p; Q) N$ z* W) O, N" L       when 9,4 then
. y2 h* q2 e  H0 {          print "square number"
. r0 D4 a3 L  K8 v  q" X# M! R$ H       else
. [' W9 n- e9 C$ p6 c5 e          print "no special number";% [+ y1 ~7 S  V9 `3 N
          print "or number greater than 9";
  K" i7 z3 r0 j0 J. s! j1 g0 K' |   end;3 ?2 Z1 Q6 O: R4 C9 b0 R7 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, 2026-3-10 02:08 , Processed in 0.018089 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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