设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9231|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is. a" n3 R- N: X: o0 D; a6 |  f
       Ci :integer; qi : integer! ?( Y8 x7 Y* }' I) s
do 9 C7 L- @* K, U" Z, k
       inspect Ci6 f+ a2 f# e# }, _2 H4 t  |( z
when Ci>0 and Ci <=150 then . z5 E+ o* ^) d- v( ?' U3 q8 N0 @
       print qi=1;( h) E7 f- B' O/ ]8 U% `1 s
when Ci>151 and Ci<=500 then- P5 h% U! R( U! b, }' O- j
       print qi=2;/ c+ X! B6 ~5 X2 e  P4 E
when Ci>501 and Ci<=700 then
! {- t( j$ F4 m       print qi=3;
% H) |- L1 D. c0 m; B  Dwhen Ci>701 and Ci<=1000 then
& x$ A2 p. ^" h5 }6 V       print qi=4;
7 y. q9 q5 I6 b- i; u! dwhen Ci>1001 and Ci<=2000 then
% @7 d$ S% }9 O! c4 b2 G: s       print qi=5;* ~, p5 U0 V: _& z9 v2 h& [
when Ci>2000 then
: E' p$ H9 g3 L. p* b7 I# [' x       print qi=6
( [2 S1 b4 A# ]' G! H1 rend;
3 L. @0 u& E+ R% U* Cend;1 [$ {! ], r6 d& z
0 @2 D4 N9 e2 P, e
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
" B/ I: v$ j# K8 o  D; w          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
& P& V9 i# F& h$ a( j/ t(number : integer)' i, J, q& i( N: V7 F
is) X4 B$ y  L+ Q9 v# |9 b5 N
do
- f9 v5 M3 a. u   inspect number
- h' V0 G$ x* E9 A4 {       when 1 then # R3 B( Z8 O: L* U
          print "not a prime number"
! _, ^; G8 Z) z% A7 R$ ^& U       when 2,5,7,3 then
1 R$ T5 D6 U  Y; C+ e          print "prime number"
" C6 T: K4 x: F/ D       when 9,4 then " c! M7 O3 y1 e8 D
          print "square number"
* O4 Q  S) M" t7 @       else2 Y1 k6 L8 ~% r
          print "no special number";
7 D: x* o# j0 d$ F  t          print "or number greater than 9";
, F9 q, }% f, [, o% l) w4 ?/ v: o   end;
  ^6 t/ b; _1 U6 qend;
 楼主| 发表于 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-15 17:00 , Processed in 0.013922 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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