设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7911|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
, V# S  I! s, S8 p) [- \       Ci :integer; qi : integer" N: _8 b) J* h0 ~8 l7 g
do
9 @  l2 e4 k% ?! D0 [       inspect Ci" X, u- s7 H3 Z' @9 ^0 a5 q7 Y
when Ci>0 and Ci <=150 then 2 [4 a$ P; n9 [- k7 l
       print qi=1;3 g. K# ~3 N6 a" L( P4 g, W9 x4 W. V/ E
when Ci>151 and Ci<=500 then- p! M* ?# Z* z
       print qi=2;+ n6 B; f1 E5 [0 ?; f7 p+ y( I
when Ci>501 and Ci<=700 then" V* j$ U  X8 I6 O
       print qi=3;/ R# X; J9 X5 B
when Ci>701 and Ci<=1000 then
6 T, {( O) ?" E7 G. t: `4 z       print qi=4;
- k, y! I, p& g6 o8 y  j( B3 mwhen Ci>1001 and Ci<=2000 then
8 l( N; V1 Q* P       print qi=5;
6 ?# Z+ u; v; `8 h0 {- Nwhen Ci>2000 then8 G! _* ~! ]$ @0 C' W4 P% ^
       print qi=6
! u- [, n1 }6 N" K* oend;+ a. b1 S+ K4 t2 q- p$ z
end;
8 a7 L  Q: ?% k6 L) _" }# i* D) R" }" A/ U
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?/ k% a; k5 S9 Q0 `- }- `* |: f, |6 _
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
+ J3 z5 L) N, @(number : integer)5 K& s+ Z) b8 _; i. ^
is
5 E  W7 C& R$ K, I) _* Tdo, H# ~5 }( r* {+ F! O  g3 Y2 J( _2 G2 D
   inspect number( o  j5 M. ~2 b" \/ U( f  D
       when 1 then * {; c8 J" m, J. i- \
          print "not a prime number"( @0 R; W" g5 c  L
       when 2,5,7,3 then ) r; O( q" Q( ^: Y5 P& W8 s7 r
          print "prime number"3 m- ]& K+ L- l( Z- i
       when 9,4 then
: ~" q  p5 E6 }! _1 y          print "square number"
  o. N/ }, r8 x* {- B       else( S, ^" t$ y3 Q7 r
          print "no special number";
7 _! V+ }- O% A- A4 @+ z3 k          print "or number greater than 9";
" a4 g+ Y& {1 B" u+ V' i   end;
7 o; R, A$ j: {* i0 S2 xend;
 楼主| 发表于 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-2-11 17:14 , Processed in 0.015844 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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