设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7214|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
% z! Z2 ^9 k7 \# w0 H       Ci :integer; qi : integer
$ i9 z3 Z# {" ]8 m9 X0 A, odo
( a( X, A8 g/ P; G       inspect Ci
. a% Z, B9 A+ {- V% hwhen Ci>0 and Ci <=150 then
+ z" n* }, l2 `# \: E       print qi=1;
- \# S" [7 J+ Pwhen Ci>151 and Ci<=500 then' m( ?" v3 Z8 l7 g3 T6 M$ [
       print qi=2;; o$ J/ b% `) h, m* Y0 {* r
when Ci>501 and Ci<=700 then5 N5 u. Z9 X7 ^( d7 i
       print qi=3;0 q8 l: s  _1 I! _
when Ci>701 and Ci<=1000 then9 p! M2 q" f" X1 V, c0 y+ H6 w
       print qi=4;$ U4 |5 d4 w; U
when Ci>1001 and Ci<=2000 then3 ]+ d* x. }6 f0 M$ \& H6 F
       print qi=5;
# U: C; `6 B" ~when Ci>2000 then
, O2 `  M# l, T1 }7 s( X8 ]       print qi=6( g8 T( z8 W: G% Q9 O
end;
' p* g6 C  B. c# ~. Qend;9 V  i- g. |4 `" \8 V

2 }- l) q5 J/ N+ Q$ F: t          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?8 ]' a7 M* G+ M( I: q8 M
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:/ M& T; S9 q' s' }( c
(number : integer)
. j0 z0 ]( M  i' F0 |7 S% ris* W( I" k" s$ R
do& p! l( S9 g# ]: I
   inspect number, k# [# D9 c! o
       when 1 then
3 G; j/ b; v$ t% N7 E          print "not a prime number"
1 b% t' }' a& {# u0 X; _- \       when 2,5,7,3 then
& l2 y! a' s9 `, }# N( j          print "prime number"* v" X) U8 `0 J: G5 `
       when 9,4 then $ b! p0 r  B  h0 {3 y
          print "square number"
/ @! @; A3 z3 l6 W- C& O0 d       else, V6 Z* p- g* Y5 K5 L+ u
          print "no special number";/ P: G* K- C- L9 l2 C- y1 H* {
          print "or number greater than 9";8 n! ^# K3 n; [9 j
   end;
$ `  ?- c% h% e2 X1 X  s1 wend;
 楼主| 发表于 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-10-25 04:42 , Processed in 0.014815 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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