设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7852|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is' j* T. _& ]7 p+ S( ]
       Ci :integer; qi : integer1 @) t& i8 A! D, A/ \  b
do
) X6 Y$ ~: P$ A: E7 Z       inspect Ci
( U; J: b2 s" ~% @) Xwhen Ci>0 and Ci <=150 then
  D8 D& h/ d+ F6 @- t3 M       print qi=1;2 {% w6 s! ^2 w) l9 u% u  E. I4 _
when Ci>151 and Ci<=500 then
- n$ Y# V# P- ?+ \3 V       print qi=2;
/ U' x/ `, ^, z% o% Gwhen Ci>501 and Ci<=700 then& Y) `/ i, v5 q% ^
       print qi=3;
+ }4 w  ^# K& c1 u9 ywhen Ci>701 and Ci<=1000 then+ n% ~1 e, E) W; }# }5 v0 H
       print qi=4;
0 @& _) ]  h5 l' }" i& D0 H$ Zwhen Ci>1001 and Ci<=2000 then
$ N) r1 X0 W: S  V; z9 d  [       print qi=5;
& G. f5 c) d6 Z2 Xwhen Ci>2000 then+ Z( U( V* E; L/ j5 N) @# u
       print qi=62 Z7 `, r4 q4 _, N
end;! O/ o( a2 V" Y9 z! h$ ]
end;
2 m6 G8 a; J- \) \; H4 k6 X4 ]% r) q
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?) H7 x  Q9 l3 o  J' O
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:. e; y5 j. _8 ^. A  k
(number : integer)
) x' E3 y# S% I0 tis
  n. a$ b) u6 Y5 Odo3 Z# \: [  m; N# D
   inspect number; y) r6 }+ Y* V% h
       when 1 then % Y6 T# t5 M/ H
          print "not a prime number"' F: f1 }% g7 v7 a+ ]
       when 2,5,7,3 then ! |5 U) D  r9 K. Q6 k" q
          print "prime number"7 M; S7 Q/ P8 B" R" ~/ [7 s
       when 9,4 then
4 s6 D: F6 z. L% Y0 K% x! u          print "square number"- F$ }3 }! _0 L- n
       else- R6 t% C1 t8 D8 }/ [
          print "no special number";
/ }5 Z% H- H) f/ v9 r% s          print "or number greater than 9";1 }/ ]7 J7 R7 s! w+ [
   end;; Q* D" f) k% f  |. T) y" v
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-4 13:15 , Processed in 0.014002 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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