设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7737|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
( g- Y  [, v' e& [" S       Ci :integer; qi : integer
7 h! X7 \. b% n7 Xdo 4 \* P5 q& p) g  p( l
       inspect Ci
5 r0 v: a/ Z1 Pwhen Ci>0 and Ci <=150 then
: ~0 ^5 f- Z$ G0 q" P. c       print qi=1;
; J. X( p1 ~7 A% Q6 t* U' ewhen Ci>151 and Ci<=500 then
+ G0 a$ u! O: a( `; _$ D% B% H5 ]) p       print qi=2;9 Z; ?9 X/ N2 b3 {
when Ci>501 and Ci<=700 then
1 c/ {& K$ B) _3 I; D       print qi=3;
5 y+ N! ?9 o& b6 U" pwhen Ci>701 and Ci<=1000 then
: W8 n6 j# h6 W1 @       print qi=4;' a% Q6 H7 c; z3 |6 N3 E
when Ci>1001 and Ci<=2000 then
; H& y$ Y; |( _: @4 L2 t0 r       print qi=5;! p7 |. m- Q- a1 n- @9 b
when Ci>2000 then2 Q: a, t/ |5 N0 z2 m9 P
       print qi=6
% d+ e: B% X9 Cend;% w% V3 |' V7 y. T8 Z( A0 N4 E
end;7 O( W/ `  ^/ \  X: Z& ?- |
5 |' v" ^, c( j% V# {- O5 x
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?8 B, a7 F7 F# z1 c( B) u
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
9 e' u  k; j) P(number : integer)
8 u9 j, {/ I4 J* L% `7 S% ?is7 L' [0 _5 I; ^/ p1 A% M5 n: B
do( I% v: s  h4 B% z4 i6 ]& y
   inspect number
- M, @  C: R1 s  h  [" x. w       when 1 then
9 t: x5 f0 ~* }8 J5 L  o* z          print "not a prime number"
: q0 b& W$ R7 @% e' n3 b: Q       when 2,5,7,3 then
( E( V( U9 [& V1 [4 x          print "prime number"
" o# c7 c+ ]: E" I       when 9,4 then # L  O# J8 |4 p& ?) Z2 b
          print "square number"+ A6 o' y# V6 m( \/ H" ~
       else
, D/ e" I& {3 H/ V          print "no special number";
4 K; ^' `7 W* x/ @% B- x          print "or number greater than 9";% `/ T0 \; X5 B' {
   end;
$ k5 W1 R- I/ b) F1 aend;
 楼主| 发表于 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-17 14:17 , Processed in 0.012322 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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