设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9139|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is/ ]; ]0 K7 L7 A: Q" n7 d
       Ci :integer; qi : integer& |& I0 w3 y4 w8 F  e0 J/ n  g3 F2 O' B
do 1 ]- u2 _, G  }. k
       inspect Ci/ t8 T  Z9 _' d. X+ V4 M
when Ci>0 and Ci <=150 then
# L- _7 B1 A" j) |0 I8 [       print qi=1;, Z4 F. p$ N# O3 V
when Ci>151 and Ci<=500 then
, Q) {% `& g/ V, p/ F       print qi=2;* _6 R2 K6 ~; W% b
when Ci>501 and Ci<=700 then
) A" X2 l& ^* U* _       print qi=3;& k& |$ ]; i5 ]# M
when Ci>701 and Ci<=1000 then# a  m: _$ \. y  o1 {
       print qi=4;
' {  w! t9 A- C$ nwhen Ci>1001 and Ci<=2000 then9 O  Z  X* k9 e8 T/ m6 x; J7 c
       print qi=5;9 ]1 L4 @/ k* A  Y* {9 O# h
when Ci>2000 then
  d, ]5 O( F; x7 n       print qi=6
9 z/ ^( X5 o1 W% V1 l6 I  Kend;
& m8 J/ `8 R7 @% fend;* s/ q7 M" S5 I! H

  {# D4 G6 z, w4 N          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?' i5 H. V: T* [# a' c' q! ]& v
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
% l% t& v1 s( D(number : integer)9 ?1 h; m' Y  l, a& _6 R6 I9 y$ H) c
is, M8 f" r3 u: o
do
! _1 q0 o2 |6 j0 D' L( b/ S   inspect number) X) I7 X/ g5 h* ]
       when 1 then
3 u: J7 e: R8 M- D. [          print "not a prime number"
% |  f6 l! R( U  Y: ^       when 2,5,7,3 then $ L3 o; ?9 {! ~( j
          print "prime number"
! v( i) y# b/ X7 K       when 9,4 then + F# q" W/ v6 I; }. {
          print "square number"
/ a( `8 S* C' s! Y/ {) E: ~8 l       else
+ y! g) u  o( o          print "no special number";2 a# v! E% q5 U; E. j7 t) B/ J6 `
          print "or number greater than 9";, P/ _, r3 g' X
   end;* l; E8 r& x; y' z0 R* W! r
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-8-3 02:22 , Processed in 0.018233 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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