设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6471|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
6 K6 @8 n! ~# _1 Q$ M( R       Ci :integer; qi : integer
" L+ `) U# n5 h6 A: E: R2 D3 r9 t: ldo
" p; z. o, g) @- _5 Z       inspect Ci
+ ^5 S$ ^. N0 Vwhen Ci>0 and Ci <=150 then
& @1 y8 Q% N; H4 B6 l2 Z7 J       print qi=1;
7 Y7 T  Z; O% T# B4 ~7 o5 ?! Fwhen Ci>151 and Ci<=500 then
& o# L/ Q4 ^; v; y3 x/ Z* w$ l       print qi=2;
9 v2 A% k/ R* g7 {, ]when Ci>501 and Ci<=700 then
7 [/ Q0 r3 E, G! H0 p0 g! B       print qi=3;
* g5 b6 A3 M2 T/ F; Jwhen Ci>701 and Ci<=1000 then; g% U  _: p( ^$ q9 Z
       print qi=4;
3 @7 R9 c  c8 j$ [8 Q6 u$ n6 ?when Ci>1001 and Ci<=2000 then
; Z1 o2 ?# \8 Q' S; u: y       print qi=5;2 q4 E6 e* b* h( Y2 r
when Ci>2000 then% q0 F% k& d* b; u6 z; |
       print qi=6& n$ s: Y- R1 O* @! E7 k/ P
end;! s" ^6 h7 ]( e7 B* K2 J
end;" c. F& s6 p+ p* J( L; G  O9 z9 w

, M1 `3 U% F1 G  k9 A  r7 ^          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
) ^# m# A( D, }" Y1 L- K          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:0 i- |( o  C6 K# F2 ^
(number : integer)& a. e* G# A! r2 \8 N& l; {; t
is
. F, o4 S% ^; p% g* J+ Z. }do. ?# O' X' ~8 r/ Y! ^" E$ q
   inspect number! J( H9 e/ \! {: R- x3 V' q
       when 1 then
0 p6 {; L$ A. z" r          print "not a prime number"
6 ]4 B; i" A# ~- `+ A       when 2,5,7,3 then 3 {/ Z5 t' r: {' E% Y5 t1 r
          print "prime number"
3 `$ X8 X$ z9 Y0 p       when 9,4 then 9 j0 D+ _1 @& t% r4 V: ~
          print "square number") j0 P# k3 D  _9 x) n* u
       else
( K# T/ c# t; j3 Y2 p) M% G* M) n          print "no special number";
) Y: P" [/ V, f) j( f& _          print "or number greater than 9";: d5 d' v& J1 o  i3 G8 z
   end;
; [+ }( w; K, {' N  f5 {1 Hend;
 楼主| 发表于 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, 2025-7-2 01:55 , Processed in 0.011873 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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