设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6907|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
$ x( y$ D" y" ], l( q       Ci :integer; qi : integer! e  x  w" ?) v
do   R; S: o! N/ @& A) l% K
       inspect Ci% ^  b4 k* p- a' V4 E
when Ci>0 and Ci <=150 then
# s( ?2 J6 F2 ~, v( K       print qi=1;
) ?" N+ b) }% z8 Z$ dwhen Ci>151 and Ci<=500 then
- u1 t. q. y/ z$ p3 E$ y: }       print qi=2;; w/ u5 G# R+ M
when Ci>501 and Ci<=700 then7 a) u) o4 O% q7 x
       print qi=3;
: {1 a; V4 R* \: f( mwhen Ci>701 and Ci<=1000 then" f) {2 i( Z4 d0 Z4 V; N
       print qi=4;
/ i* u+ N5 P) ?) f4 Jwhen Ci>1001 and Ci<=2000 then5 i9 w/ j0 \  W5 c2 }. C* L6 r
       print qi=5;; B( j! A# u+ r- Q3 q0 J
when Ci>2000 then
! c- u* C$ K: \2 R" P       print qi=6
  q( N  W  k5 A- L( D+ w8 y4 L5 Xend;
/ J# S9 B# }6 [8 l* k( ~end;
) m& @3 u) y: _# Q  d8 ?' h; K/ A- l7 u3 m1 d* Y$ N1 R% `
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?* O' [( w: `3 k4 ~/ z# \$ H
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:( H! m% K8 s5 h" F
(number : integer)
  J& l3 Z7 B6 B/ {5 {  tis
: E) q# i8 X# S  D/ x4 Ydo1 ^# t# }+ P! a( p1 f
   inspect number! Z" }8 I  f) W8 @. N1 l5 V7 [* U
       when 1 then
* t& n% @: |( i          print "not a prime number"1 v. I3 G+ R0 T3 y3 m9 d- g
       when 2,5,7,3 then 1 W7 l; u  V7 c) {2 L8 h7 I6 X
          print "prime number"
' Y) v- u+ y+ Y8 _4 d/ h; O       when 9,4 then $ S5 `2 R8 Q* l( k9 Y- o2 }
          print "square number") y  r# |( f& ]6 g2 @# Z9 E5 [
       else
( l- n, V$ }. }4 c1 \          print "no special number";
. U0 B$ ~' u  B. S          print "or number greater than 9";
" _; X8 S* s* y8 ]8 a   end;
3 Z, l7 \  Z0 W% jend;
 楼主| 发表于 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, 2025-9-11 06:01 , Processed in 0.014802 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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