设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8692|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is, C) v5 ^7 c. v; `( M
       Ci :integer; qi : integer/ H" w; z$ ^6 ]: t' w8 \. {- ~& F# o
do
% V( u& v1 Y5 E( \       inspect Ci) ^9 |  Z: g# C2 m
when Ci>0 and Ci <=150 then
* b; S: A" A/ Z1 I4 c8 w       print qi=1;
) e. e, P9 r+ O1 d: y$ C% Qwhen Ci>151 and Ci<=500 then
( Z7 q; D/ |3 t$ ]: P- Z1 a8 r& _       print qi=2;$ l# ~9 I5 _# t3 y$ f
when Ci>501 and Ci<=700 then5 t9 y% f3 I; ]* O
       print qi=3;
* Q% I% e$ e9 j* C' \when Ci>701 and Ci<=1000 then- V! C; }5 x% f0 V8 ?4 L; k
       print qi=4;5 K$ S: P5 R' C1 E% V7 |9 P
when Ci>1001 and Ci<=2000 then, H6 ^" e6 {) j
       print qi=5;
5 J; b" z- d+ X2 Y2 i8 E* a# Hwhen Ci>2000 then( O. j4 |7 K% S; W% x0 K6 p. \
       print qi=6  C1 B  @$ P/ n% K7 F: }$ t6 }
end;& V. i" H- N  g# V: D- p
end;
- L, M. n8 A, _/ O6 j
& w3 g& Q! q: X+ W7 f8 `          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
, m3 h9 [  S, `/ l          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:' s) u" u6 I8 `: }( L
(number : integer)
( o! S( }6 C% s: H( }is
, e) _8 G* Y: q3 u  sdo% ^( c& Q7 j: e" ?+ A$ \  t: l
   inspect number
+ v' f0 v  F$ x; Z       when 1 then 2 G5 L4 L2 m/ C5 _1 M. g. P* X
          print "not a prime number"  {2 f) _3 }4 b" S: y
       when 2,5,7,3 then 3 J) T6 V/ F' B0 {5 P0 j5 j' K
          print "prime number"
* c( d0 b3 y' Y% F) z       when 9,4 then / C$ W% t5 v; R" |4 S. w) {
          print "square number"" K6 i$ y6 |; x0 _3 @  y
       else
5 i. }* A3 {" ~! R& J          print "no special number";
- b/ F. P0 ]* u$ ^' }0 C# F# d          print "or number greater than 9";" N% o0 q  r1 d6 V# ?
   end;* B1 a: r5 v- l
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-6-9 06:43 , Processed in 0.013653 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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