设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8778|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is- _; F( Q7 E+ D8 ~9 n
       Ci :integer; qi : integer- L2 a- W" [* J# F) ^
do / L" O: p" }3 R
       inspect Ci/ g% X1 R7 W) u6 p+ d0 J. z+ ?
when Ci>0 and Ci <=150 then - y2 M. t  `3 p2 A$ w0 i
       print qi=1;
+ y& l# J+ T/ E9 [5 [( Gwhen Ci>151 and Ci<=500 then
  \# M3 s4 ?. U       print qi=2;! U2 @, j, r; i/ i2 J, R& K3 _
when Ci>501 and Ci<=700 then
. A$ K" s: w% C; W: b4 t! t       print qi=3;
8 e3 V( L# [$ l% t( l6 @when Ci>701 and Ci<=1000 then4 s  t9 }: n7 E# M$ ^
       print qi=4;
7 R- s; V/ Y. l- k* h0 a, E# `when Ci>1001 and Ci<=2000 then& ^* j; c& x+ S7 Y
       print qi=5;
9 g7 M% u7 ]4 N' N  }4 W: q8 J, dwhen Ci>2000 then
+ J, n/ z: ~0 Y       print qi=64 J( G- k$ Q) A. {! W- T
end;2 ?$ d" O' C; q7 _
end;
; \! q- j2 {( e% _; w4 T* G, R
. d9 B0 U/ l" ?$ V+ }2 |: ?0 Y          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?  n) d! }/ b; p% e
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:1 B9 x- c4 f! \) i
(number : integer)$ e0 Q8 l% m, k5 v* `" T9 |6 j4 ?
is5 R& \5 V6 T. G
do
$ N0 v9 G' \) L  G4 r* C8 S0 C   inspect number
* B/ E1 m# }; i% g0 y8 Y       when 1 then 0 b9 Z2 @, e- e1 V$ P. t
          print "not a prime number"$ g! N* G5 P; ]9 Y' f
       when 2,5,7,3 then
* U  a. D# j! u+ b8 h$ w          print "prime number"
$ d# I8 k! a( ?" R       when 9,4 then
& Y& q" p8 O% M4 H4 W3 h1 D' @8 _          print "square number"6 d: B8 \8 Y2 I0 O: t
       else/ ^3 ?) l2 S3 f( j
          print "no special number";
) K# l: U! T7 z" }( }& S* t8 G- k# D          print "or number greater than 9";7 e# G2 u0 g7 ^' d6 y$ W
   end;6 q/ V+ m5 D$ a( B) V6 S0 p
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-27 09:38 , Processed in 0.015585 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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