设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4596|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is2 l' K! O4 A$ h9 S
       Ci :integer; qi : integer
3 F' S4 S' K* C- Y) L! ^5 C- hdo $ O4 K! r/ V* h# ?' x0 v' p1 n
       inspect Ci# b) S; j1 }; e
when Ci>0 and Ci <=150 then / b8 |4 {. K& Y5 B5 i+ L
       print qi=1;& C' p; H+ A: B% h0 U" D. f
when Ci>151 and Ci<=500 then
& ], ^# t7 I! k       print qi=2;8 b' y% K+ E; Z! F% L6 t- i
when Ci>501 and Ci<=700 then- @2 w% e* r8 V; y) M- p. E
       print qi=3;
) l* {  m0 n) Y" n  [+ ~& s, bwhen Ci>701 and Ci<=1000 then9 R) `- M7 u, v/ f- }( [4 l
       print qi=4;+ Y& c1 U  a, H4 U" ^7 t# ^
when Ci>1001 and Ci<=2000 then
1 C6 N* f2 p1 |+ |% D4 g# g6 L/ ~# i       print qi=5;# X; U" j0 l* B6 s- k
when Ci>2000 then
( P5 G6 X9 X) o% H- J0 o4 a1 ^5 b       print qi=6# x6 e2 Y8 ^9 _
end;5 T3 m( ]. V2 u. [% \; P
end;
& ?) s9 S- U3 z% t/ ~9 {6 B
+ Y5 w, S4 R: n          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?) `9 e; n4 W% W- S; X
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
, v' p5 ?8 n" I(number : integer)* v0 H  T% H' h5 `0 B
is
/ d+ n8 Z6 T  C  c' }9 pdo
) z# K/ E, ^1 l/ I- B   inspect number
' v2 l5 U0 Q0 D! V, n       when 1 then + M0 G- u0 G- g6 q4 t& k0 A
          print "not a prime number"
: j7 V2 j# Z7 `' N       when 2,5,7,3 then
* s, C6 D# `5 A4 m. @# w( F1 o          print "prime number"
+ x$ m5 ^7 J% O" C. B       when 9,4 then 6 [% G0 V5 r. m6 m
          print "square number"% W2 W+ F& ]) y
       else+ c! c% Q( Y- a
          print "no special number";- }3 f5 O) J8 x  L' j& g1 Y
          print "or number greater than 9";( u+ w: K3 U9 r) z
   end;. r2 V) R1 X1 d$ J
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, 2024-6-2 11:00 , Processed in 0.018158 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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