设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9401|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is* P7 j* N9 \# M  S- ?1 @
       Ci :integer; qi : integer
5 o# h7 x  g, e. Mdo . _% y2 q! s1 K! P' V
       inspect Ci: g7 k  {" N& N; Z  b% W
when Ci>0 and Ci <=150 then
- j3 O- R8 |1 ^6 c" H6 E% d; _* {       print qi=1;
8 a2 X1 s* I7 ?/ `when Ci>151 and Ci<=500 then, Y, k5 d' `* [! ^( L$ `  o
       print qi=2;
5 t2 s: P! w: x% d8 Wwhen Ci>501 and Ci<=700 then+ z2 o; B* ]1 ]# l8 l
       print qi=3;( g/ ^& t' L* t& _
when Ci>701 and Ci<=1000 then" F- V/ n! M3 X% ]# z" ~
       print qi=4;
0 X+ g1 O3 ]# l! m9 \when Ci>1001 and Ci<=2000 then& ]! h/ |5 ]5 q* v
       print qi=5;
# C; }) G( l* b4 P$ q# c& |when Ci>2000 then% P  w. g7 M+ {% M% O: R
       print qi=6
% T& `! q6 E8 @6 k2 send;9 J: N' e, R4 Z# W- ?3 o7 s0 }
end;
/ F  I- b6 H2 i
4 M# \  W" O$ D+ B1 s2 ?' T          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?% F8 O; y; a2 i8 ?
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:8 {( D. M, Q8 G- i# b" x+ q
(number : integer)
6 v7 K( _9 h! r$ W0 Q8 Mis
  F$ j2 w; L; h9 T+ |) C* Xdo9 ?, b3 U$ K2 x' W
   inspect number# s9 e) n0 b0 s, j7 E- P+ L. x1 |
       when 1 then
9 ?. V$ U* _" l9 D, R; M          print "not a prime number"
% a* d, `: e; t/ U       when 2,5,7,3 then   s5 A7 h$ B! Y! S& T  y1 m
          print "prime number"; L. b  y( T7 i& ^" e+ S1 A% u) \
       when 9,4 then
8 _/ y- n/ @, I6 j          print "square number"
. k7 T( S0 P) K- _' m       else) Y; k$ a; h6 K% o( Y$ A
          print "no special number";
# r0 Q) [/ O: f* S          print "or number greater than 9";
% h4 Z! K& N0 W, s- ^7 I  n, W' R+ [. h   end;
1 o7 U+ F2 m9 |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-14 04:40 , Processed in 0.019168 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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