设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8326|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is8 U  L( m+ i: n$ }
       Ci :integer; qi : integer
- @( D/ _8 f  F; a0 e! s% v; @8 k% Zdo ' ^+ e( {7 x6 M) q  h* B
       inspect Ci3 V1 ?$ W7 t: y
when Ci>0 and Ci <=150 then
/ M2 ~/ C! E* V3 m4 g, I: z3 R8 y       print qi=1;0 u' W) b, g$ J9 I/ {
when Ci>151 and Ci<=500 then9 P! d( \/ V5 _$ ]8 N
       print qi=2;$ _" \6 t$ B& E6 z$ |5 c; g
when Ci>501 and Ci<=700 then, t* Q0 |$ ~5 G) Q) ~
       print qi=3;) U* C& r2 {$ U
when Ci>701 and Ci<=1000 then
; I) p- x- {' J$ }8 M: L! h       print qi=4;
# k7 r" ?& Y( y5 j- U8 J) U! f3 ewhen Ci>1001 and Ci<=2000 then
5 x, H+ v, m2 m% Q2 q" P3 u       print qi=5;. ]8 G4 f8 x! J. y+ |
when Ci>2000 then
3 T8 r! Z  o  ]/ }5 @       print qi=6& {: M3 [8 F) w6 N) y* a$ ~  b$ O* ^" a- F
end;& [3 }3 M! e* x1 S' d8 N& O' A
end;
8 f& ~+ g. R* v9 s
# ]6 y3 ^! j; a& @9 s8 O          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
% \, C1 ^. C. I( k) y$ A8 S          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:% g) r& q0 i- A/ N) o$ P+ u& E
(number : integer)
. w( ^- z5 Y; |* c0 T# Y# P" Nis2 _5 ~3 M8 N' C
do  M# z# {# w! `
   inspect number
- {  T4 O8 ~6 D& D8 s       when 1 then
! q. F6 F$ G& V8 s8 P          print "not a prime number"
1 W/ Y0 b% R( z+ w) ^2 J! K       when 2,5,7,3 then
' i8 t. Y) k" [          print "prime number". L& L, s7 ~* V7 H: d
       when 9,4 then $ X+ _! i% n2 [( R. N
          print "square number"
0 m" O" {7 P& }' S2 n4 |+ _0 _4 {       else
; _2 z; O7 @8 a% k% Y; t          print "no special number";
0 {  X5 z) T# w# U" s  q          print "or number greater than 9";1 B, i3 M( k! B0 T1 H7 O! y
   end;
; v4 c+ W# \; \: c( e$ w; d: mend;
 楼主| 发表于 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-4-17 13:05 , Processed in 0.021388 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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