设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9392|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
6 N9 ^. Z9 d% j$ a! `       Ci :integer; qi : integer$ [7 z2 |- b0 @8 F
do
: U% Z+ ~  C" P9 G% \4 d       inspect Ci
) \& X2 F0 p- }' O, {1 g8 pwhen Ci>0 and Ci <=150 then : P9 J+ ^' v; k) q
       print qi=1;
: g; M5 v- ?5 F3 B# u3 @6 lwhen Ci>151 and Ci<=500 then4 M; i4 H) Z7 l- y* C) g" F
       print qi=2;
4 v) ?( w" M5 N5 Qwhen Ci>501 and Ci<=700 then9 ~$ q! m  K" C! ^" q( s( D% ?
       print qi=3;
  C3 k$ g- z1 q! l% z3 Dwhen Ci>701 and Ci<=1000 then
! y" v5 x+ e" F" Q       print qi=4;
6 u9 n/ ^3 L# W  O; D* x" Dwhen Ci>1001 and Ci<=2000 then% L7 ?% c" c5 A) B" H% I* ~9 B# U: w
       print qi=5;+ Z4 q0 v2 d2 @  H
when Ci>2000 then
6 c- i. R# @7 w5 y; l) u4 J       print qi=6" m5 m) ]3 A8 M8 j/ X; x
end;
) ^7 d( O. c+ I4 |end;
3 ~* p8 m) o: ^6 w$ }/ ~
3 F+ ~% j2 H! l5 l6 a7 e* {          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
1 J1 E6 K* l: a; z          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:. x( U; }+ D. S
(number : integer)
+ X- p9 Z6 W  Q+ c3 ?/ I. d; V- lis
; B1 j6 I) c0 z% u+ Q! T4 D1 gdo
* {; }% M1 @2 ~8 y% @  C   inspect number
/ j2 i8 ~* }' Z0 X. O) T       when 1 then
( T! P+ w4 H9 \6 O& X5 r          print "not a prime number"2 B$ h+ h9 n  H+ m: k  O7 L
       when 2,5,7,3 then $ x/ U% T) ~/ g) Q* \: H5 Z
          print "prime number"5 w6 j; G' }+ T2 S6 g2 Y
       when 9,4 then 5 K9 x  O4 v0 j: b; C; s
          print "square number"  q3 w0 i, h/ _2 Q) y6 N9 t6 M( V* C
       else6 i6 O- R) |) D, X2 l9 M  S: C5 `
          print "no special number";
3 ?. W6 ^! {! r: D, Q. V# O( L  i          print "or number greater than 9";
& w6 R! Z& U" N9 o+ P; n, N2 N$ C   end;" F! U/ e8 D! C0 R: d
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-9-12 05:47 , Processed in 0.012694 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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