设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9232|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
  m, D: {6 ?& M3 R4 I       Ci :integer; qi : integer
  Z( H' b! y  E6 Xdo 6 K; S: l) i4 Q
       inspect Ci
. n4 _  c5 V9 h8 jwhen Ci>0 and Ci <=150 then
8 o8 f, z5 ^! _' w/ V       print qi=1;
- t+ H# p& L8 n$ }5 Cwhen Ci>151 and Ci<=500 then
1 e+ r/ y# M( W  d! s* F       print qi=2;
( G# i1 x% x" E7 L4 k  owhen Ci>501 and Ci<=700 then
- z2 o7 c* [" a; j! G9 Z: O  l       print qi=3;$ G3 a7 _- P1 }+ t. Q; e) X9 j
when Ci>701 and Ci<=1000 then. E0 F' j% f# n3 @$ l
       print qi=4;+ b! V- R; v9 A# x' [8 j- X) D
when Ci>1001 and Ci<=2000 then' G& s/ t& ^) n2 {4 x6 S5 n- R/ e
       print qi=5;
* I6 c! h7 B( O1 V$ Z* Z5 Twhen Ci>2000 then
1 G" X' y& ^! Z' V       print qi=6+ L8 h7 {/ g  C0 v' j9 z( }
end;
1 l3 [/ x* q+ y1 J7 [4 R; oend;8 E) Q5 \& z" g5 B; @2 Q

  O2 U& F, B* F0 l          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?" h8 O0 X- f; {3 j8 K2 i
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
. m1 W- M" Q$ O7 p(number : integer)
8 A: B. K) r" A; z" Zis$ W/ V; O( C& C) O5 j7 h
do  L4 f3 G9 i. z2 N
   inspect number
+ D; c6 f2 G3 O$ V       when 1 then
1 C4 c; p/ m( w' k( Y7 Q+ T0 e          print "not a prime number"
( J8 W/ g7 \( y8 _2 w' \; R! ]       when 2,5,7,3 then
/ E" n( i' H/ i( B+ R. m0 b9 ]          print "prime number"
- d  t& g' g& r. G0 k) o7 w0 a       when 9,4 then ' ]/ e+ n! h% E: ~4 \) u) h
          print "square number"# C+ T' t& U; o- r" l* @& F
       else: ]) b) x' V+ ~- R. C. n
          print "no special number";
; x6 @# c. M: K: v* G' g& @/ T- h          print "or number greater than 9";
( N1 J$ [3 f! u4 M% ^- L; c4 C/ t   end;7 W- p) P/ {4 M; C3 t' k5 k
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-8-15 17:01 , Processed in 0.015704 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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