设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8587|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is9 ^, x7 F+ [5 L) L0 E
       Ci :integer; qi : integer
- {2 s$ b+ Q5 X% ddo 3 D! x& F7 T9 z
       inspect Ci- u. l( f* x- v
when Ci>0 and Ci <=150 then ) q# m6 G# k1 k! A- w4 ^1 |
       print qi=1;
; }: s# Z7 f$ o  S6 Nwhen Ci>151 and Ci<=500 then& `$ W. a8 J+ V0 U- W& M: b
       print qi=2;
/ i$ ?( u6 m5 K& f( Uwhen Ci>501 and Ci<=700 then# _4 q. q0 Z1 l
       print qi=3;5 B1 @$ M: g& }5 }/ V! U/ {8 m6 S
when Ci>701 and Ci<=1000 then
9 n3 C: u4 Y* Y3 o; c' z$ w/ {+ X       print qi=4;/ F) d5 O: T& x/ ^3 }0 `
when Ci>1001 and Ci<=2000 then
" k+ X/ {+ @" H+ g5 |5 F  E3 ^       print qi=5;
9 }0 l. f0 L. N  Hwhen Ci>2000 then
+ a: n% S: }- J  v* e: w       print qi=6
! s, S3 l* c4 ]1 _; _5 L: s( r, Rend;( z. h  v5 ?/ y0 G+ @
end;
4 _; a; W" f2 o! C! u3 |7 v; {: C/ z$ U" v
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
9 [' B; q; X# U+ z' d& C5 a7 e2 T0 O          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:+ w" h9 K2 l- a! |# f
(number : integer)4 M$ B; s; T. o' {
is
/ P# V3 Z, w& L7 C% [% {4 |do' q8 R( d; C: W0 X7 g
   inspect number5 E7 R' F+ M; Q4 K* ^! c
       when 1 then
* c& C' |( _" x- B          print "not a prime number"8 q4 {( p+ X2 [  H, ~) _
       when 2,5,7,3 then
7 i  {; L/ y" m3 j+ X" }          print "prime number"5 B+ `- H2 Y1 [, `
       when 9,4 then ) S8 n& u+ }" y2 ~
          print "square number"5 b0 H) ~! x% t* L  C5 i
       else9 Q  \( ^! d4 u& z; i# {) ~
          print "no special number";
  B+ y: w+ y3 t/ e/ X8 m( h% T          print "or number greater than 9";# C( E' H# k2 c, ~% d" z
   end;3 G9 v& K+ m2 H& D. p
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-5-15 16:09 , Processed in 0.021865 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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