设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7748|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
0 Z% l+ G9 d9 `- s! z       Ci :integer; qi : integer
3 Y2 S  n) F7 m3 F& ^, U2 Ydo
1 e9 R* P5 s( o; l1 `1 L- R+ C4 {       inspect Ci
4 D/ U4 M* \2 w7 i$ nwhen Ci>0 and Ci <=150 then 8 g/ s3 e; b( T( ^3 T
       print qi=1;" E# d3 V- `/ x
when Ci>151 and Ci<=500 then
/ b. _7 `' G6 O% O) S       print qi=2;: a3 Z/ Z9 o& W, B9 q( u
when Ci>501 and Ci<=700 then: v# p( X# s: M3 z- o5 Y# D
       print qi=3;! `4 j) ^! ^' |1 v' j9 }! U
when Ci>701 and Ci<=1000 then
6 l$ @2 V0 N4 T* M8 J# _* F       print qi=4;# W$ C2 e! ]* e$ m# I4 q' N, v. P
when Ci>1001 and Ci<=2000 then7 m: v" z4 G- B; V: ~
       print qi=5;: ~; ]& v/ u; @% k7 W3 {
when Ci>2000 then+ _2 ?) d. K5 f5 P
       print qi=6
. x( y) ~3 `+ A! u3 T! jend;
5 y! s) a" Z. g5 U" U- k9 aend;, Z: t, t8 K7 N) r" E" F6 F' F) ]
* m4 G/ f, E8 |8 u0 r( b# A
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?/ Z5 z3 S/ X3 m* i# N
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:/ b7 _: ?2 _! Z, C5 e7 E
(number : integer)
7 p" |! R, d8 eis
- P% E0 [. Y: l/ _7 ^6 p- A! @+ vdo7 d( o6 _+ O" Y( _$ B
   inspect number$ O- {" n+ ?9 G
       when 1 then # {7 F) B9 s2 X# W) T
          print "not a prime number"
. Y2 z( p/ h& S& t. M1 P       when 2,5,7,3 then
* g; h# g3 W  t8 ]( @9 ?          print "prime number"
% M* G4 \/ v- J$ c! U$ `3 Q: [6 R       when 9,4 then   K5 Q  U3 ^: K# u: Z
          print "square number"! _( Q$ B. J4 y' O; e7 l: |
       else
- X/ p) a$ }" N+ J" b          print "no special number";
  e) T) L* h6 r, d) y, q3 F9 d          print "or number greater than 9";8 {) V6 \) T7 J* {
   end;
  u+ C, E9 L% H" {5 M) {! ^' Send;
 楼主| 发表于 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-19 12:51 , Processed in 0.014304 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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