设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8881|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
/ F/ P. ^* b  ~7 G, h$ {8 @- t3 v0 Y       Ci :integer; qi : integer
  |8 M8 M- _7 z/ `  q) ?5 y( |do , U2 s5 y, R. N3 i1 [& l' s+ J
       inspect Ci
- Z+ g, i' X3 R0 nwhen Ci>0 and Ci <=150 then % D( ?; m% N" _5 m6 I
       print qi=1;! p, k9 Y# R, M% E4 f2 _% N& B+ S
when Ci>151 and Ci<=500 then" [# ~! a) G' w: ^( t
       print qi=2;3 ?/ ]: z& [4 V0 a, i
when Ci>501 and Ci<=700 then6 {5 Y8 o* x0 F* w3 b
       print qi=3;
/ u. P4 o1 |# R  B. a0 Wwhen Ci>701 and Ci<=1000 then
: @8 i8 w, \  [  o. X) c7 q       print qi=4;1 ]" d' p  }& }  @" B2 C
when Ci>1001 and Ci<=2000 then; f: G: F7 D1 H2 o- d
       print qi=5;: Z5 p! D' j6 M' m
when Ci>2000 then
$ @7 r4 i- q* g9 q8 u- |       print qi=6
4 u7 X. Q& P$ m- v$ U( gend;$ s7 h4 z/ j. s: K* \8 j# \" v
end;/ a7 n4 {- c( ]  b$ m% i
9 n& f! O0 P. D' N! Y
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
7 l+ n% K2 O: U& ~2 [* o7 b; p          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:0 ]6 ~) d& S3 n" l3 h
(number : integer)
( K. B/ K$ G1 A( K  ?% uis6 z/ O8 W( N; _; S
do
, F; G$ B, O: ~( i9 U   inspect number
0 {# K) W+ ^! `5 ~  o       when 1 then
7 G1 y# d0 O. D. l3 ]          print "not a prime number"4 A3 q& E3 D; u0 W
       when 2,5,7,3 then
' E8 [( e1 Q# ?. v& p$ [  P7 G/ j/ B          print "prime number"
1 _6 t7 v3 W7 [6 b7 Q2 F       when 9,4 then
" J! Z: d% p% q. x- s          print "square number"
, {9 g6 d# T3 Y) x5 ?: S# c6 q6 ~' p       else
8 x! n" r$ S6 S          print "no special number";2 ]: x  _9 O3 k" |
          print "or number greater than 9";
- n: R& ^. u8 {9 f   end;
! S  @) n7 M2 g# f6 yend;
 楼主| 发表于 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-13 05:09 , Processed in 0.015557 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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