设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8597|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
- F7 B8 J! e8 n; C" U" T( i( L% I. v9 S       Ci :integer; qi : integer$ G, ^4 s3 F0 Q9 B8 \$ V6 T' z, q
do
! f& q$ U$ l1 g9 r0 H       inspect Ci
8 v, o+ W6 r2 U: hwhen Ci>0 and Ci <=150 then & y2 G3 t0 D0 [& ]- a% J& k
       print qi=1;
! i2 K  g8 h) n# E* \! cwhen Ci>151 and Ci<=500 then" F9 I* x' F! i
       print qi=2;
0 r% y) B$ b' C0 N' l2 rwhen Ci>501 and Ci<=700 then9 }0 j& O6 _/ A" m
       print qi=3;
' q# A" m9 k' Ywhen Ci>701 and Ci<=1000 then" S' I% K3 ^% d& r9 H
       print qi=4;
+ _$ f) q" b& n( o3 l1 W8 xwhen Ci>1001 and Ci<=2000 then- h2 X! ]( N$ Q( W  ^. C
       print qi=5;( v* d  m0 K* ~' J& [# e: b
when Ci>2000 then9 E2 U9 m9 }& K2 H% `
       print qi=6
* Y1 b- R' W: [# b/ U& d  t: d( hend;
+ s) L. z) H* U7 T1 ]. [8 c* Qend;
9 ]- q5 Y3 m' F: p* u7 X
# C# O* t% A% E; {" P5 n2 I: l* N          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
# ~7 @( X# a" w1 H! i          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:$ D1 V5 r8 d+ @
(number : integer)
2 Q8 X0 {3 b5 s( U" y' \) k" J* Y9 wis' C& d9 q3 s1 L* i2 I2 i/ [& m
do
1 `$ u+ n- P  n3 Q9 r& p   inspect number
- O! J/ l" L$ M% v; v9 N1 I       when 1 then
9 N- D$ w8 E; s1 j) L          print "not a prime number"/ n3 N: w7 G% F5 q2 d& z5 _
       when 2,5,7,3 then 9 [! H! j. z" d7 ~  s# [
          print "prime number"" U6 b$ T7 r5 S: V+ l! M
       when 9,4 then # c# e8 O  I8 |4 B! x" j
          print "square number"3 y, r5 U' @- T7 D5 b2 G
       else2 t( o' y7 C& w( J0 @+ d
          print "no special number";- b" o* w4 W4 H0 |( A
          print "or number greater than 9";
: ^- r$ s3 R6 h9 s2 g   end;6 f. M4 @$ G; z; m/ Y0 I6 W! J: J% [
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-5-19 10:56 , Processed in 0.016506 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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