设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8334|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
% k8 x+ f7 Y& V' O6 X9 }. t       Ci :integer; qi : integer
& h2 z1 l4 ^* u. P% Q2 D1 Ddo
; m7 L& ^6 x; e& z4 ]" P       inspect Ci/ p8 G* z5 i- N; {5 ]/ _" s; @
when Ci>0 and Ci <=150 then & y$ B8 u# ~0 ^1 B
       print qi=1;  ^1 ]4 o" q& t$ x, T! R3 |3 P4 ^7 b
when Ci>151 and Ci<=500 then
5 r8 n4 g$ a0 ?: T4 `; Y- U       print qi=2;
. g+ w# G" p. g6 q( n/ }) ~when Ci>501 and Ci<=700 then
& w/ S3 m/ k$ C2 X       print qi=3;2 [5 ?& C+ R' Q7 h
when Ci>701 and Ci<=1000 then
) Q& `: b: G% O/ g1 L6 Y       print qi=4;; Z0 o% I- y( J5 f2 m/ L
when Ci>1001 and Ci<=2000 then5 A4 J% I8 H) o, Y7 I
       print qi=5;
8 n- t( O+ d2 @  Y0 Dwhen Ci>2000 then+ L0 \# Q, G/ P) j5 F; w' Y
       print qi=69 \4 f  b2 e$ M5 h9 o
end;
3 G+ }+ l1 P/ q0 ]$ Wend;6 t& Z6 r5 D" C. V2 k% s6 [
' \" {8 I4 C0 N
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?1 r1 }4 M; W& b
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
! A* k& I: r) @% i" f' w; |(number : integer)
! ?7 ?  c; J5 t( d. e! s% S! {7 }) wis4 N7 z. \( D& S$ B- n3 B
do1 H( B6 P! \9 [6 J3 R8 N
   inspect number8 Z( Y1 d4 _& @5 |8 @& D, B
       when 1 then
  A1 [) H. U4 l: [9 K" B2 A7 k" D          print "not a prime number"
' I0 }& h# p* `; ?. d' ?       when 2,5,7,3 then 6 W: ~$ u2 v3 g3 M3 }9 [
          print "prime number"# Y' h$ i7 {$ N# d
       when 9,4 then # p: y6 d& V1 m! I8 {0 L- U1 I; Y
          print "square number"
- u1 d/ b! b0 J( H       else/ f' }( j2 W: a+ S! C% L
          print "no special number";
* B9 s: A" m* Y9 S2 g          print "or number greater than 9";
: F( S4 O0 q1 }$ F- e! L/ y9 @   end;
" R; y! q" ~! c/ \, W9 P8 N& \. Y* }0 Aend;
 楼主| 发表于 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-18 20:40 , Processed in 0.012874 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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