设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7653|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
& ~0 l" Z- \! S  {. S5 A1 Y       Ci :integer; qi : integer" A0 l2 P% Y( V2 @& z1 h
do . R$ e+ U4 n# s% }) L' `
       inspect Ci+ H0 `% ^! c7 Q
when Ci>0 and Ci <=150 then
6 R% M* x$ T' U       print qi=1;
# c) P% f+ B3 a) ywhen Ci>151 and Ci<=500 then
  F: u' w# o- c2 L; H/ n       print qi=2;
- i: l$ E+ j( C4 c+ ]when Ci>501 and Ci<=700 then7 Z6 y8 ]$ z: S& }6 n
       print qi=3;6 G9 @5 g0 O1 @$ i
when Ci>701 and Ci<=1000 then
" ]7 N+ @0 [$ R       print qi=4;
! K0 L" T7 k7 s) P, @+ }# \when Ci>1001 and Ci<=2000 then4 V- Q2 Q4 E2 s# r
       print qi=5;( {* Y6 A' X& W9 I4 f
when Ci>2000 then
5 W3 A3 h, n- p( X' V: E8 d       print qi=6+ Y) O' Z- u1 V# z
end;
+ ~1 ]6 _' M, s7 Vend;
( S" h; b- V4 n) A
/ _6 h$ j' x8 H: b+ F1 Q7 e% n6 C          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?6 P7 e# R( w. S+ N0 c
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:0 ?1 Y# w$ T4 Z
(number : integer)
% c" F! E6 ^" Pis8 u+ a/ }, R% j9 V% I
do* M8 t# q. i& E* K3 E. N8 T
   inspect number+ I$ ~6 R& p- ~* p
       when 1 then 0 f3 V# ^1 p) Q# \# V& p- W+ D
          print "not a prime number"
) x1 f- i5 G1 l7 R0 n  }; s* F* `       when 2,5,7,3 then
; G5 |1 s% g/ T, f          print "prime number"
$ N0 ^# t) L- @/ h       when 9,4 then ! {/ f, o; P$ c, N) ~$ S4 T8 T
          print "square number"7 f7 j+ v8 Q# |7 D" |5 y" v
       else$ R! j3 o2 u, p. c
          print "no special number";/ Q5 }# _# ?# F9 G: C9 d
          print "or number greater than 9";6 W5 r/ {* |5 y# a5 r* k( s8 A5 z4 E4 Q
   end;
& W$ Q0 N0 l7 O. H9 |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, 2025-12-24 09:17 , Processed in 0.015228 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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