设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8034|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is2 m+ I% w- j" ]7 F
       Ci :integer; qi : integer
- L4 z8 s7 R' J* B2 hdo 5 B/ E) c3 I0 _2 [$ c- F
       inspect Ci3 w0 Z4 I  T8 Y' O  o3 _
when Ci>0 and Ci <=150 then
5 e* L$ x3 s1 F# s- y) X       print qi=1;
; Q) w9 U  i, uwhen Ci>151 and Ci<=500 then
, @2 d9 J  o  ~- E       print qi=2;
3 ~, I/ F6 I* r- U6 q5 cwhen Ci>501 and Ci<=700 then
8 T, x' ], D' b5 i       print qi=3;# `7 m; {0 w; z$ H
when Ci>701 and Ci<=1000 then, e3 s, I) h2 _1 C# q! p/ a$ w# Q
       print qi=4;* y: L: _6 n" n$ s+ J8 _" C0 k
when Ci>1001 and Ci<=2000 then
/ h6 w" g2 t% u1 g6 t, _       print qi=5;
$ H, x% |& Y1 Hwhen Ci>2000 then
& ]& {( O! |" f- b1 K$ h& Y) o       print qi=6( z5 _& z4 a) v
end;
: I7 h1 V3 P, G6 A- Dend;
1 z% u0 Z1 p% ^( n. ^
3 j+ V# s" ~3 D          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?* t% t1 c: }6 U
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:0 y5 J: k" d9 u4 O% t& V
(number : integer)
( J6 o2 E) {8 o& t# R" O, L4 lis1 E* `! l: b3 w7 M5 A' o/ J. N
do) q$ ?* S0 @3 j7 d* z+ |3 E/ W
   inspect number* n7 S; {+ H5 o3 k. y$ b7 {- ^
       when 1 then
$ z: r9 [" g+ ?( @          print "not a prime number"5 }" L8 A  t8 b0 W/ `
       when 2,5,7,3 then # O$ [; y' k' E- {  Y) p5 @$ J+ Z
          print "prime number"
7 c) I. j+ W8 W' N3 |       when 9,4 then
9 C8 l6 v- m/ D; Y. g( v) N! c' c          print "square number"
* l) [6 n9 q: h) H! I6 y# I       else/ D" ]; ?" Y" W' G! l! e. ]
          print "no special number";
: V+ K0 g. @  Y0 M          print "or number greater than 9";8 z! ?, V; Q; z9 F- j* K& k1 U# I; M
   end;
+ }9 G, Q3 x: Y- dend;
 楼主| 发表于 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-7 05:55 , Processed in 0.020143 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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