设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6968|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
6 J! {9 L/ V0 c: e       Ci :integer; qi : integer
4 j" b1 i7 b, Z1 Z$ K( Q0 p" [  fdo
. _9 x) w3 q/ @0 b& ]# e       inspect Ci
# e3 x) O+ c& @5 v/ \4 F4 L+ owhen Ci>0 and Ci <=150 then * G3 I8 o0 f0 R
       print qi=1;) f( v. Q4 u; P; N
when Ci>151 and Ci<=500 then" i# P* T: u. z5 W7 b
       print qi=2;
% ^3 L4 A9 g* w. @when Ci>501 and Ci<=700 then
8 [2 G* k. n" C2 W+ ^       print qi=3;" k; A9 M, U6 C& K  }. K6 `
when Ci>701 and Ci<=1000 then% c, R( B5 y: W+ d; C: M/ w
       print qi=4;
: M9 r4 X2 V7 E7 fwhen Ci>1001 and Ci<=2000 then$ d6 ^7 B3 P. {. @3 \
       print qi=5;- x! ?5 x/ ~! V4 J: e  q5 v) z
when Ci>2000 then
3 b. U! g& }6 I, M3 D       print qi=61 F7 D9 z# b# ?, }( ^5 g
end;
( X; s. H& M6 G7 k6 y* `end;
, j- x8 G; v% @. g4 V! o- `4 q$ e  ~/ {6 l" T
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?4 n" e2 ^' |7 |$ [
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
6 l$ X' P' p  w" D, f(number : integer)
3 P# w" S* f$ O% Z0 \/ s! iis
9 _/ M, k* L6 b9 Ado, ]- F/ L0 w9 A& P3 l
   inspect number
/ P- P" s! p) V$ ?: B0 }       when 1 then
: p# x( P* E( q! b; z8 g          print "not a prime number"4 `- D2 x/ z; J
       when 2,5,7,3 then
3 h0 s4 Z& f$ @5 `" s, H          print "prime number"- @" d1 E* K8 H5 a8 w
       when 9,4 then ( c$ H+ g9 M+ R) v8 y7 p; b
          print "square number"5 z% ?; f  r/ l8 n- X+ X# f
       else
8 L/ p5 b2 o- G* t0 l          print "no special number";
( }8 m* I+ o4 r4 i/ \" Q          print "or number greater than 9";8 n7 D" g1 {. C. K0 q
   end;
3 y" B1 Y3 w: Z8 K+ G6 send;
 楼主| 发表于 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-18 14:31 , Processed in 0.015857 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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