设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6940|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is& v; n# n8 V. I; w; R
       Ci :integer; qi : integer
+ Z/ V& Z  k! ~4 cdo
6 L( o8 A, p8 S( I       inspect Ci
* \/ d  F% Y+ pwhen Ci>0 and Ci <=150 then
  F2 K# m9 ~$ i& F2 I- r       print qi=1;
* A, T3 L- r! F, U' Pwhen Ci>151 and Ci<=500 then5 V5 U- p7 x; W  [
       print qi=2;, _' j7 j$ k2 Z# n6 U) ~. W1 l
when Ci>501 and Ci<=700 then
$ Z" I+ h% |$ p. x' a       print qi=3;
) E9 a4 r" k9 l* A( Rwhen Ci>701 and Ci<=1000 then/ i6 P5 }0 a$ p9 u7 _+ z3 m7 B' W7 k
       print qi=4;& V" K+ P. ]) c: V" A' O
when Ci>1001 and Ci<=2000 then
& p  d( O; K' F+ p# E       print qi=5;  T, R* {. i  U$ M7 T$ c
when Ci>2000 then
; ]. h, I- C2 p5 q% ~       print qi=67 a1 S2 X: `! t8 z$ a! `+ ]
end;. f5 s& A! F# y
end;8 N. k+ u3 p! K2 O/ e

2 w) s, Q  v9 ^$ ~) s# g          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?& L8 A/ w2 W5 t( A0 G0 l
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:" @- a& i3 }8 ], A
(number : integer)3 R/ K' P# }* {8 C% a
is& K+ f8 n, Z4 ]: g
do% f: X* s$ J: L! n! s$ a
   inspect number4 x/ |3 W; t( M1 A% l; B+ p
       when 1 then ; [- P6 d+ V7 K$ S6 W7 W
          print "not a prime number"  X3 d. x) z( r8 t* y
       when 2,5,7,3 then
/ T: T& A" f, Q  d2 S2 f1 \- g          print "prime number"
7 j/ n) }7 M0 K: w       when 9,4 then " D0 f- x5 C7 H$ `+ u. ~3 o
          print "square number"
- B( X; C. t; W1 b$ r/ ^- G       else
, c8 R* Y4 p: x% k+ B          print "no special number";
/ g$ [3 M# L, R: e4 h. q  p          print "or number greater than 9";
& z9 R3 i6 \1 ^$ i" C. V  f   end;
/ `8 o/ W" ~$ e) {$ a! O7 r" f0 |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-9-15 22:19 , Processed in 0.014698 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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