设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7844|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is9 `6 e$ ~4 n' h$ }# Q8 k( v% L, \
       Ci :integer; qi : integer
$ E. J. a# A6 z$ g$ h1 bdo # p4 [: q2 y2 b4 l- a1 t
       inspect Ci& v- I5 R% s+ I, K! l9 i
when Ci>0 and Ci <=150 then 1 ?4 c4 L- }) g0 q! y
       print qi=1;. `! x+ ^: z4 r# \$ ~; L4 C
when Ci>151 and Ci<=500 then
9 K& {) Y3 n* j9 G. x       print qi=2;
0 L8 S. t; x8 h3 f3 ^3 J  B6 \$ ^when Ci>501 and Ci<=700 then% S2 M2 P3 b% y+ g. {1 Y
       print qi=3;# u; K0 l3 g, x
when Ci>701 and Ci<=1000 then  s. O: _+ j  t6 d- H0 J! @
       print qi=4;) K8 z8 w$ \% W, t/ I
when Ci>1001 and Ci<=2000 then: d4 p  N4 p! \  |
       print qi=5;
* ~: D5 b  @" n. ^9 J, {when Ci>2000 then% `4 }6 W/ e* o: \. B
       print qi=61 Z8 a/ e5 g8 B# Y
end;* ]5 d5 y( I" i, ~! Q; F
end;7 f! r. h" m8 K4 R( ^. O
2 ]# l, H* c+ `+ l$ o: m, @' @
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
) G* C- |( X( K7 B, r: Y          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:% ?8 Z( k# t/ |$ R0 q
(number : integer)
* w% [8 \, H& o; i- t: k9 ?is% J7 p) V  {$ g/ ?3 |
do# @% d: Y$ a, I! z2 r
   inspect number- V( @- u3 F( k
       when 1 then
* Y) v: \- I( E0 d          print "not a prime number"
; H8 p3 J- |, m. c: j. u: ^& `3 g       when 2,5,7,3 then : `+ T% T, n, P- s
          print "prime number"0 F' X1 \8 x2 z+ j" l  |
       when 9,4 then
, @) ?8 c+ r# I2 c: W1 r# x# N          print "square number"# ?! I: E/ z: P! Q0 k5 w8 h
       else
% w# r2 ^, R& p2 J          print "no special number";
5 r* C! N! {9 u          print "or number greater than 9";0 j0 ^: w% W+ U/ n$ j; N: F7 ^" q
   end;0 g& K  K' p; y* Z$ e+ C
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-2-3 01:13 , Processed in 0.015430 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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