设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9188|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
* u' q  k& e" f/ c& t0 Y       Ci :integer; qi : integer
4 F: Y, R. d7 {9 }/ ]: w6 Ddo
% ?: }4 G8 B9 m9 P/ Y) T4 o       inspect Ci( n" Q$ U2 C2 m0 H4 U0 D1 `
when Ci>0 and Ci <=150 then   D7 W; ]$ I$ M
       print qi=1;2 F/ P& F+ l" C+ v6 K
when Ci>151 and Ci<=500 then
; b( t; k9 S+ q) X. ?       print qi=2;
* z) j6 }. t) y* i" Lwhen Ci>501 and Ci<=700 then7 R5 o) |) P! `* V! @) ^% z
       print qi=3;
! K$ I( U$ F9 ?, _" Gwhen Ci>701 and Ci<=1000 then
% f% Z( m, K- `. ~! m2 X  b* y       print qi=4;. M' [1 y, l/ f1 Z$ u: S1 ~
when Ci>1001 and Ci<=2000 then
, U9 u* f* n4 J! }4 [       print qi=5;, G1 T5 p1 A& I1 b+ T, N
when Ci>2000 then
) ~9 ?0 _0 m1 E' \4 e) V# ]4 n9 O       print qi=64 J3 c. H8 J; c9 M" n7 g/ g
end;- q  N4 z4 {1 u" {  ?4 ?: D
end;
$ X* i- y. v# O% B% M/ I. M
. V4 T4 o9 @. `0 q" s( _# _/ ^- A3 x          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
  z1 H' n: ~' \# ~          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
" [. Y4 O/ g4 M! v$ m7 e' I(number : integer)3 }. R( L; m9 q5 [9 k5 C: {% D
is
# M3 n! E" M) d. p9 d6 l& `do
# r+ O3 e' g5 G8 Z1 Q7 {9 G$ w/ `   inspect number
7 R' d1 @; ?' T" i1 a& A3 K8 W       when 1 then
! x7 N- U; }% y1 J! M) z7 A          print "not a prime number"
0 n& u. a) G& B3 z& F  d3 s% s       when 2,5,7,3 then / |4 F. s; g4 ~$ v
          print "prime number"
8 L; y8 |" l0 {6 T& ~- ^       when 9,4 then + v  G. A* y6 r7 I$ z. v& n
          print "square number"0 U5 c0 L% n. P% w1 t. M% c1 l
       else. q7 P* i' G4 E
          print "no special number";  T2 Y+ N% m6 h  ?8 N. @1 @
          print "or number greater than 9";  A- T1 e3 D6 z! C8 D
   end;
1 v" `0 n; _/ X5 _4 wend;
 楼主| 发表于 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-8 22:45 , Processed in 0.014346 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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