设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9172|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
, ^6 T$ @" _  c3 I/ F       Ci :integer; qi : integer
/ l9 Z0 M1 K5 |- Ddo ( l$ ?' ?* ~6 O5 }3 g+ E( x
       inspect Ci
* g* s$ p+ p  U# x9 gwhen Ci>0 and Ci <=150 then
& d4 l& t  [# ~6 e$ B       print qi=1;+ h/ I! v- R4 [6 ?" b
when Ci>151 and Ci<=500 then# }( d+ p: B! o) ~  h
       print qi=2;
& ^% q0 J, @0 r" l3 Owhen Ci>501 and Ci<=700 then& k: W. c0 G  }* `
       print qi=3;
2 Y1 H$ u/ n$ @when Ci>701 and Ci<=1000 then
6 {4 I. @( u: a6 {       print qi=4;
; N! }4 k: t/ _1 {when Ci>1001 and Ci<=2000 then
2 U. b6 c& @6 j( k       print qi=5;6 }% P* g% @' |( o! d) |* r* N8 V1 P
when Ci>2000 then0 }: f% s# h' u5 x2 s4 e/ X
       print qi=6
7 \4 K1 @( P! R6 M* q- Mend;
# W  g% n* c$ _7 G8 ~" m- Nend;
" |2 ]: ]2 x& N1 R* F- H0 w
4 u+ h) u  r/ q: p9 c          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?6 [6 x: e; `5 T9 P
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
: D+ M5 Y) ]/ b0 c(number : integer)
2 d. y; S' X: L& _8 W; Vis5 ]  \) K3 o3 w% H- v
do5 r* t$ |/ |5 q/ V7 H% r
   inspect number
& L# m! K  ~5 y: W       when 1 then
9 a* [3 l: h: a6 d4 o! W7 g9 F          print "not a prime number"3 B& |# t7 a( R0 n* L
       when 2,5,7,3 then 8 e7 q8 R( R+ s; s# t( a
          print "prime number"
$ V% }! X4 @+ F. A8 m       when 9,4 then
% `) k" v0 J8 b+ J; e; r          print "square number"5 E0 `7 D# h5 u/ G: P
       else
) }0 e0 q; y0 ^) `  A4 _! O$ b: ^          print "no special number";
5 E2 x8 K6 l# V' g          print "or number greater than 9";
8 A0 p, M: B; k: J   end;
& Y& E* e5 K0 y1 I% H! Kend;
 楼主| 发表于 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-8-7 04:04 , Processed in 0.013055 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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