设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7825|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is1 Q) T1 S& y* X5 G7 n1 ]
       Ci :integer; qi : integer3 }6 |$ A$ a$ Z0 }" l& f; _* t) F
do , }, S3 T7 ^/ T: f# s& L% F
       inspect Ci1 _6 p( G" U) t- `( r" k
when Ci>0 and Ci <=150 then 4 {! h. d3 |1 s/ R$ F) w
       print qi=1;& w/ {: W: h. f0 e2 c
when Ci>151 and Ci<=500 then0 I6 N# O: D8 ~* w* _
       print qi=2;
' t; f  {' {. _5 W4 y$ c. Wwhen Ci>501 and Ci<=700 then5 b4 I+ J9 u6 {' C5 {% ]' o+ O3 f
       print qi=3;! V8 D/ \$ e" ~  s& N
when Ci>701 and Ci<=1000 then$ ]7 J2 |/ E/ o7 f0 j% n; K: h- v, o8 s
       print qi=4;2 d9 G5 J1 i' l. w
when Ci>1001 and Ci<=2000 then5 V5 ~! u% _- \% I! Y
       print qi=5;+ \* H  [. O8 z8 b
when Ci>2000 then
+ @2 H6 j  F9 s& \       print qi=63 `' ~4 B6 x! N4 D8 A+ R
end;
9 c2 l* g4 x8 oend;! x! A' |; Q1 z; Y$ W* K8 n8 d) M

8 N- R: N0 k, U0 c  m; n/ O          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?) R9 O" X: Z( Y5 G
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:  a- [! w6 ]& {
(number : integer). m) g5 g0 J3 z/ z5 e
is
0 ]1 \# S9 L- X  X. l: Gdo
0 d- m2 t( _% a9 H) Q. C   inspect number
( {9 @! U( r: `  Q# I( u: o& k       when 1 then
  ^, Q" ^% T( C" j0 U0 R          print "not a prime number"
' e' r# S: E- W9 C       when 2,5,7,3 then
/ J# a0 F1 E% _* K9 R          print "prime number"
- l& Z2 y$ y' A. r# O       when 9,4 then   u+ I- X/ S- J; Y, M! `  t
          print "square number"# _* f# {% Q9 F
       else
2 [6 ~2 y; W- k' L. I  Y          print "no special number";/ Z% S8 R8 o/ z0 c, S; S* [
          print "or number greater than 9";6 n6 c4 G1 A3 P6 ]( j' l
   end;
% p8 K1 ^) B* D/ z) K) q. {) U1 ]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-1-30 20:45 , Processed in 0.012359 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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