设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7674|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is3 i1 M" V: Y# E  T' l
       Ci :integer; qi : integer
9 V+ @% A8 w3 r' |: ~do . z" i0 {( A' k9 Q2 y
       inspect Ci
, f% F/ x! M$ O7 Xwhen Ci>0 and Ci <=150 then
6 z# _) O- y+ R       print qi=1;. U: g7 ~% v" J  u2 _; l' G7 y9 u
when Ci>151 and Ci<=500 then6 g# x" k: s: F  ~3 T. g
       print qi=2;
) j3 m8 h" D* Mwhen Ci>501 and Ci<=700 then1 z0 p, B& f: h+ q' h' H
       print qi=3;2 _! J8 o$ J+ ~1 Z
when Ci>701 and Ci<=1000 then
' u! H* M, ^2 L+ n0 W& `       print qi=4;
/ b1 B! W0 w. Fwhen Ci>1001 and Ci<=2000 then+ W  T4 G1 {0 q& T7 ^3 i+ j2 D
       print qi=5;( P$ N: B  ^% ^1 B) f
when Ci>2000 then
5 w% O  i7 v( a; V! k  L8 D       print qi=6$ Q2 I! G9 x$ i# W
end;
$ c& L4 v3 @7 |! H1 L( Nend;9 b) ^0 y9 j: z- A% B5 A
, h- i" ]8 h/ {6 n1 Y
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
  S2 T* T: N  K& f( D; X( ]8 y. Y- ^          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:4 h) H) I- T7 I8 T
(number : integer)
& v+ M, Y9 F! g$ G0 T) h  gis
; D% u7 D; m) zdo( Z/ j2 _0 x6 x" Q( R
   inspect number! \* T( M0 j! k' L% s
       when 1 then
6 z3 g9 x: Q9 }          print "not a prime number"
8 B  L% m- J. z0 {       when 2,5,7,3 then : b6 o9 I- L2 v$ M5 D
          print "prime number"
9 ~% T: m: f# }4 f: h       when 9,4 then
3 V  d1 p4 g, X0 z, ~; c          print "square number"' L: y" p. n/ T! M
       else
3 A# n; s, @8 Q. ~3 `          print "no special number";3 `. r, W' j* x$ k1 }
          print "or number greater than 9";9 P: z; n6 ~( j/ f4 T  E+ j* ]
   end;! [0 j+ e$ A& A
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-29 16:29 , Processed in 0.017250 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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