设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7687|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
) o/ ~& {7 m8 @       Ci :integer; qi : integer
6 s2 v' Q$ Q+ T8 \: Odo ( p0 c( \. D1 C" Y9 a  P) `$ o
       inspect Ci
1 [7 a: g' s) `. g7 L- \  {when Ci>0 and Ci <=150 then
- ?7 r0 d$ C9 s- S7 m; Q       print qi=1;
$ V8 m6 d9 v) M( _when Ci>151 and Ci<=500 then; U: L' _1 {9 K6 ~# v
       print qi=2;
- N/ A, ^2 ~6 r  \" M5 j  Nwhen Ci>501 and Ci<=700 then  @5 B4 {  a, B0 y
       print qi=3;3 E7 r; V9 c5 d6 C) f6 v
when Ci>701 and Ci<=1000 then& }! R7 p4 U9 S, f
       print qi=4;
5 V( y2 f3 _! Twhen Ci>1001 and Ci<=2000 then8 b0 G3 p6 i" ]8 Q: y( i& F
       print qi=5;2 q- c# Q6 A, g& G. `
when Ci>2000 then$ z4 N3 O: F2 _
       print qi=69 r: {2 K" {. n4 Y/ d; D, m2 i6 i: Y
end;* x& }% Y( p- ^2 f; i" G
end;
0 i$ Q. [1 ]* |3 w1 P. g- z
" Z1 q2 Z+ U' i! n          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?, J) ]( B0 A1 Z) Z$ r0 @
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
- Z3 a; L# V  Y) A(number : integer), G) |9 F0 b( R! a+ Y
is# M9 [3 J# ?0 O/ o- q+ F9 Q3 \4 B. L5 i
do  Z  T0 e# V0 I( o/ s
   inspect number
& s2 W  [, V& N: d! g1 s       when 1 then
5 j) W* \$ d$ l' h3 i          print "not a prime number"5 E( ~6 X/ y8 |  F/ D5 g* j
       when 2,5,7,3 then   e8 N; z! \0 ?$ T; B. t% O/ J
          print "prime number"
1 Q9 h1 l' G7 g3 d       when 9,4 then 9 u5 Z# e5 Z% o' ~% i# i% U9 F
          print "square number"' T/ o7 u, N- H) y! i% g/ V
       else
9 a  @& p) W5 \" R          print "no special number";% o( E( W+ ^$ I# A
          print "or number greater than 9";( ?2 G) V5 x0 t! r# R
   end;, i7 ?5 D% k0 R
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-1-2 13:39 , Processed in 0.013683 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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