设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8794|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
; u* w' n" q4 u. b4 S% s4 T: g       Ci :integer; qi : integer( }2 t* g  j0 G, h
do : p: t6 A: h+ N! F" Z5 t
       inspect Ci
, d- I) I" w" U  E% Y) E0 Owhen Ci>0 and Ci <=150 then
1 f2 ^8 j5 G* i9 V$ M. ^- I       print qi=1;
* a9 T9 C. W! }1 i6 N* q8 `when Ci>151 and Ci<=500 then
* ~+ @) O: \2 M+ @       print qi=2;- t7 X- k) {4 r8 u+ q& Q8 W( U
when Ci>501 and Ci<=700 then  }+ x/ Z8 f* w  k$ ]* ?
       print qi=3;
% {* h8 j4 `% N+ Y: V8 V# jwhen Ci>701 and Ci<=1000 then
! e: j1 J; t4 d$ O       print qi=4;
6 u; Q- Z0 Z( y- ]" |% f; Lwhen Ci>1001 and Ci<=2000 then
# N4 p9 v( d2 K5 s       print qi=5;
; K- l4 W; o9 R8 _; Xwhen Ci>2000 then
9 Z+ m( D% t) L# a5 N       print qi=6
. p2 R- f# B1 _6 oend;
0 C7 c: V4 N2 H) ]7 C/ Z6 U# Hend;
7 x) V( m8 ~# z4 l9 z$ `
1 ?7 a3 m! R; s" Z0 p% [! o4 ^0 o          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?- r+ R. k( O( w! l0 Q
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:- ]3 w* D% B" T, K0 {$ v
(number : integer)
' A$ h" D  N# ~( t# uis$ ?4 B4 X9 f! u
do& X1 a; I$ J6 N0 H8 ?6 P- S6 y8 _
   inspect number
0 i  ]+ z6 {! M# j2 z" o/ Y       when 1 then
1 {: E4 G; G7 \2 a+ }  v          print "not a prime number"  }1 B3 P7 x+ L9 d7 L9 b: [
       when 2,5,7,3 then
, R2 T5 S9 O2 {+ A) N          print "prime number"" i3 H" M5 I; E- Y2 S3 @- v
       when 9,4 then . T! D+ h$ G' D6 u) n) m- H
          print "square number"
8 Y5 E+ u4 ?/ b! P) z; K  n3 [       else/ E3 T) h4 j6 M+ a3 L' u
          print "no special number";, _, `" }  A) F( A5 \! v
          print "or number greater than 9";5 b) v% L& _* G' V9 h- `1 ^7 v3 ^
   end;3 G" y' l/ @9 g+ d) Z" F
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-6-29 12:42 , Processed in 0.016294 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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