设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8961|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
. H( O- d3 B$ Q; g) q6 q       Ci :integer; qi : integer
) O0 ]8 k. m- L/ u# xdo
5 j- m, O7 E0 w       inspect Ci, ?# S- d  [/ y% m
when Ci>0 and Ci <=150 then
1 a8 z- E9 ~5 I, }; G, e       print qi=1;9 n2 H0 W$ J3 _. P
when Ci>151 and Ci<=500 then
2 {9 b! M" z" B       print qi=2;4 O8 E  z- p) g, f% y0 S3 E: _5 [
when Ci>501 and Ci<=700 then
5 N( i+ C6 E: c+ C       print qi=3;
- J; s, I$ f6 T) zwhen Ci>701 and Ci<=1000 then& A/ C( ^8 z) F) Y
       print qi=4;
+ w  S' c. c' Iwhen Ci>1001 and Ci<=2000 then
, |: Q! ~5 y) q# ?) y2 _: Q       print qi=5;
& i# f$ T8 l0 F% U& U  xwhen Ci>2000 then; A; |/ k; K& d
       print qi=6
& i0 m1 X7 W+ L" U" `4 xend;
- }  h, t+ K6 p; K* Tend;, i/ a# m) N( e" Q2 v4 ^
- {7 N- m8 Q: }( K
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
( b3 S, j9 f: h$ r% j4 k          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
" m: _4 P; `! v+ E(number : integer)
/ p8 {: c& s/ A3 P) H+ c% lis
  B. d# y; U1 m4 ?, Udo
& L, n' d6 k+ j2 V) L. f   inspect number; a* |: j% ]- }" n2 I
       when 1 then
( K9 d" A. y+ d5 ^* |" g+ @% p          print "not a prime number"8 D5 e% B! {% x5 N1 O8 A! [
       when 2,5,7,3 then
8 B6 s! \; O8 A/ c          print "prime number"8 X. }: R% F" Q, e
       when 9,4 then % f; {7 ^2 f" d$ z/ p2 \: I! M
          print "square number"2 y& K0 p( g7 a# u! B! n
       else( ?, |0 u) A6 m  r  y, u& I6 ^
          print "no special number";0 l( w  _% R& Y! ^! a5 }% [
          print "or number greater than 9";
- w1 `4 i% @, ~, M8 R   end;
  i; G( M- y+ J# W- U5 R+ O7 Lend;
 楼主| 发表于 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-7-19 08:55 , Processed in 0.011250 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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