设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9397|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is; F. k2 l! O% i) Y$ G
       Ci :integer; qi : integer6 |0 ]4 }5 l! d+ ~) f
do
6 p+ \$ r7 f2 T; S, i       inspect Ci8 `3 f# H( R2 Q& u4 S8 y1 W
when Ci>0 and Ci <=150 then
. Z6 w+ t  e; A6 l( l" D       print qi=1;# e" Y5 S* i. s0 n  d" T  K
when Ci>151 and Ci<=500 then  _" g4 ?  F+ a1 s) i8 H6 g+ Z1 R/ c
       print qi=2;# i1 [( n, F) |5 y3 K
when Ci>501 and Ci<=700 then
8 F0 w! X5 X# Z5 s       print qi=3;& ~: j4 {3 ~: w' J
when Ci>701 and Ci<=1000 then3 n5 K& `" U9 q& q6 X* z
       print qi=4;' }2 N5 U6 Q  q9 T& s
when Ci>1001 and Ci<=2000 then
& X3 l0 d5 S, y$ D0 ^' ]7 p       print qi=5;$ X4 K- @7 T: _
when Ci>2000 then' F  a9 b: j4 a
       print qi=6
& {9 ]" h2 z2 ?. i) Qend;
! V# P  }& s2 U& Y2 x) s4 wend;
" w! D& I/ ^; g4 S4 U8 \
/ o, L( G" n- G9 t! \8 F; y          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?! A! O; n3 B: Z- A: g/ p
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
" X8 D# v& }2 H# [$ L, `/ ^( H  V(number : integer)
4 m  Z0 X9 {/ e! {8 v7 bis
% y0 ^' x: Q. vdo
/ M6 e. L2 k. @. i5 R, D   inspect number  {% e. ^" Z6 ]5 ~; Y
       when 1 then / ]' Y+ {1 d' _% F. n- u
          print "not a prime number"/ S3 ^% v9 o/ t/ A8 i
       when 2,5,7,3 then
+ g( r' c+ D' o2 x          print "prime number"
  O. z' U# }. z% @5 b       when 9,4 then   W' T$ `% C/ t6 d2 k3 b& w
          print "square number": M0 s! Y% S3 O
       else3 [' V- o- p% k4 _  z, X% B& _- X: p! L
          print "no special number";! h9 E. ^0 O2 r$ ~: w
          print "or number greater than 9";( O$ h* l4 ~# H. K
   end;
# c3 [  r9 t7 ^' M; [6 l* Yend;
 楼主| 发表于 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-13 00:14 , Processed in 0.014506 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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