设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8817|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is, k2 a: j; `2 u
       Ci :integer; qi : integer# ^7 Q; ~! A( Y/ B$ Y7 q
do
; w% r( i) K3 O- q; U( v7 @       inspect Ci
8 e& |. ?$ B, a, v4 i/ Y6 Y) ~' Lwhen Ci>0 and Ci <=150 then
8 u8 g+ S: y; `       print qi=1;( s" v2 |: X% e9 U
when Ci>151 and Ci<=500 then
$ O2 B/ X8 Q% E& R" D" ~/ Q       print qi=2;
5 z  n5 }' x& |: G& z* a$ F9 zwhen Ci>501 and Ci<=700 then  I" K) ]$ W6 g: ~7 a* @- I4 c, X
       print qi=3;
' O1 R* h! J( Q  e0 t& y# H5 W1 \when Ci>701 and Ci<=1000 then( ~! e' y2 C8 w, k' {0 `6 t& B9 k
       print qi=4;
9 M/ j+ A2 z0 q( B8 O* mwhen Ci>1001 and Ci<=2000 then
7 _, W7 D6 ^; U/ ~: ^! ]& v       print qi=5;" h, T" y6 L$ n& h0 [: {
when Ci>2000 then0 V8 O" J, p& N+ ]
       print qi=6: @4 A+ B- E1 M- {8 {& u! J
end;
& ^0 F1 n4 }* n# p+ Kend;
* I8 Q8 }% h8 g+ p) c
+ r  s4 J* w3 Y' g% u9 e          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?% \# J+ `5 h( P, T
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:6 X, i& k* J- m5 J  e
(number : integer)+ H& j5 A' A; Y9 h7 ?
is+ @5 m: b0 Y4 b5 ?+ o# I
do
  T8 T* R) G  Q; U$ \  c3 w  v   inspect number, Q' |5 e) Y. k4 T$ n& Z
       when 1 then # q7 K& D' M+ x7 Z4 \0 x1 {: e
          print "not a prime number"2 R/ }% R0 ^( E2 W( m( f. O
       when 2,5,7,3 then 3 }  M5 r5 M* Y2 f  C
          print "prime number"
' `8 V$ I6 ^0 j( q3 H& d: \       when 9,4 then
; q( o* r7 T9 U  w* Z5 U0 u          print "square number"
5 s. G' Z% A& G       else. l% c( x- q% b8 x8 X" y
          print "no special number";6 n& C' `$ L# H
          print "or number greater than 9";( b/ N0 p8 u9 x2 w$ u* O$ B
   end;
( {' x: h' X  V# E& w- N. Gend;
 楼主| 发表于 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-7-5 19:48 , Processed in 0.015772 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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