设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7422|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
4 y$ n4 W5 `. f       Ci :integer; qi : integer
$ Q- e- i% y$ Z0 T1 o, Jdo " t* g; w0 B& V3 J& |4 M
       inspect Ci; F) T% Q$ O* z6 I
when Ci>0 and Ci <=150 then   G3 S: S1 D/ L. ?' C" b* c' X
       print qi=1;
2 F0 A7 q# x0 }; Z* Swhen Ci>151 and Ci<=500 then# N4 A& ?+ w( y+ A$ N6 h
       print qi=2;
' ?% W5 S4 t/ d" U, Wwhen Ci>501 and Ci<=700 then
! N' a, d' i$ g  I/ h; H8 C       print qi=3;
8 D2 A! M5 D8 p: K  {% s; fwhen Ci>701 and Ci<=1000 then  Z& n* {4 s8 W4 f
       print qi=4;
! h6 w/ r. J- E, C6 ^0 ywhen Ci>1001 and Ci<=2000 then
" i; ~, r) [' d2 ^! O       print qi=5;' P% A* @; ~7 M3 y
when Ci>2000 then4 @9 c% [/ X7 A2 ?8 y
       print qi=6
$ B  C, y, r3 ?end;
* x& b; k0 q  v% i9 G  Cend;2 d9 U' w2 [0 P$ z( i

! w: l" q$ |* i9 }          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?/ f/ Y' Z( X" ~) i
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
$ V7 o. }( p, H0 k) B: r3 `3 Z  q(number : integer)
& n- k5 r7 O6 y( T* _8 F- j6 his
9 Q0 g% j! m& K; ^4 Wdo
% K( y) `. M- f, P: |   inspect number- v: _9 Z8 o3 T
       when 1 then
3 M1 F0 G, B; u          print "not a prime number"4 C( l* p  M. e7 Q; Y
       when 2,5,7,3 then + |/ ?: y  w, f5 V: ~% U
          print "prime number"
/ _5 q/ j' K+ Y' s9 Q8 Z       when 9,4 then
. T  M. G. K4 ~1 j' {9 i8 T          print "square number"* z8 c5 L" X: b( E
       else7 |8 e! _: d; V; s9 c
          print "no special number";
- ~( d& e- _8 s. X2 {          print "or number greater than 9";
# ~: N1 x: z' h# K, k   end;
1 f4 I) S% [, V* `; v; e) send;
 楼主| 发表于 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-11-22 13:20 , Processed in 0.016672 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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