设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9057|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
9 b) @, X- v9 a( _       Ci :integer; qi : integer
% G( J7 W; ^0 A/ H! \- bdo . X; x! D( B) r6 v7 y
       inspect Ci
6 M& n/ r# Z% `6 i) F/ Xwhen Ci>0 and Ci <=150 then
1 V' a& ]$ M. q- ~" y6 ]       print qi=1;! g( m9 ^6 c6 n1 U0 S& f
when Ci>151 and Ci<=500 then3 b# r( }" g$ y1 d6 V) w' O8 G/ W, C
       print qi=2;
: D4 _; \# q/ u8 ^when Ci>501 and Ci<=700 then. b+ F/ G; R2 j& O; l2 s# \( }3 _4 f
       print qi=3;: @5 I# H3 f& k) L+ b; ?8 T' u; x
when Ci>701 and Ci<=1000 then
2 ]% L& W: b# g5 P       print qi=4;
+ O. d" P7 E! o6 u1 ?when Ci>1001 and Ci<=2000 then5 x9 Q& n, e0 N' W  y* J
       print qi=5;; ^% `& C2 k, y; K
when Ci>2000 then% U! B5 Z# N0 B# Z6 t) e
       print qi=6! ?1 w$ I& a' O6 B' _( a! R, `
end;' s7 y) W; f! J+ i0 _: f, W
end;
8 b1 z* B! R$ ~* g9 q1 t5 w. R3 v5 ^' ^# }6 {
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
3 i) F8 q! `3 y% I9 ~3 R          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:* m; i4 |! O5 l( Q/ `- K  r
(number : integer)  D8 z  z' U+ _! b
is1 s+ m6 w. W, {% w/ m+ f
do
+ [# z* D4 B  Y   inspect number
4 U0 x* q: S0 k3 d       when 1 then
8 Q$ V) ?& }; J4 ~) Q          print "not a prime number"% h9 ~% p6 V- W5 {
       when 2,5,7,3 then
) k$ k: B. b- F. y4 x/ ]          print "prime number"
6 x0 H& q( t3 t4 _) o       when 9,4 then
" n. `! I, a  o! r          print "square number"
1 Y0 ?: B% j0 U7 o       else
) o. c, a9 s& @          print "no special number";7 Y, O- e9 L+ J/ W8 g
          print "or number greater than 9";+ C/ p' N5 X* B; n
   end;
' O. q0 M0 N0 f* I7 d$ J6 Y( d# A$ K; qend;
 楼主| 发表于 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-7-27 11:50 , Processed in 1.685745 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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