设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8352|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
2 }3 b, V5 V6 z/ K1 W       Ci :integer; qi : integer
+ V2 G3 P8 o" P; }1 R( i! u- Kdo
6 [$ @/ |9 R+ v+ }       inspect Ci
4 K# d1 J$ w0 m3 d9 Ywhen Ci>0 and Ci <=150 then
/ E5 y8 \) S' T( }/ k8 f3 O       print qi=1;
( `% O3 Q& y8 e* swhen Ci>151 and Ci<=500 then
. b7 A% v# T- X       print qi=2;
  `" m$ H( c3 G% O0 e! [when Ci>501 and Ci<=700 then3 z" y1 G- q0 S5 g' Z
       print qi=3;: v) I& ~2 Y* l# I7 Z
when Ci>701 and Ci<=1000 then, b; Z. ^* U+ |3 @
       print qi=4;
5 X# z# D) y0 U& bwhen Ci>1001 and Ci<=2000 then* c2 u9 G+ k! ~* ]1 l+ g) I
       print qi=5;
( \1 S) N( T' ?: P! C+ ~0 qwhen Ci>2000 then
4 H& d  I4 {/ e       print qi=60 f  w( {/ w# |, r/ x/ J
end;3 i- X  U* M. _. b. u9 o' `, w
end;2 M+ `7 z  C; j- N* h" i- B
. y# g) q- C" f2 z8 h% S4 w
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
# f0 Z! j# H  x1 \% b          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:* v" K' Q7 Q- w
(number : integer)
" `: I6 ?. r+ [) E3 x0 Ris
/ Q' I% y3 p/ A4 O% F( C0 ido
5 E/ W) e8 G6 N' h# o# ?   inspect number8 i3 z" O+ L0 a5 K) P  s: D$ r  _" y
       when 1 then & ^( L1 K2 j7 y4 k; g0 D+ A
          print "not a prime number"
& m: N) C8 \6 B, e) D       when 2,5,7,3 then ; D* @) M6 `6 R8 ~% y
          print "prime number"% @. J9 G& G3 g) l
       when 9,4 then
9 D: a, T# O/ ?  U5 `' e          print "square number"& m# y( u1 _: S. v7 _2 H. n
       else
; B2 N4 T/ |; @6 ~  _1 F          print "no special number";8 h7 X: \/ o* u6 ^
          print "or number greater than 9";# S& l+ j. B+ D; v0 \8 z& `
   end;0 H* W" I( g% }' [3 |* b
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-4-20 11:36 , Processed in 0.014001 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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