设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8779|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
+ `2 i" e# {* F! e& }5 }       Ci :integer; qi : integer5 i7 l# w- q# A5 N
do , e/ U! z7 `! d
       inspect Ci7 }3 Q2 f" e- h9 A1 y& p
when Ci>0 and Ci <=150 then ' @+ P' J2 n7 B+ E. S, U4 x
       print qi=1;
6 x! A0 d% u/ t9 E5 Vwhen Ci>151 and Ci<=500 then. {! b& ~9 _0 t/ }# n% R; c
       print qi=2;! I6 Q( I; `/ n5 Q. i+ z
when Ci>501 and Ci<=700 then
4 m' @. S/ f6 f3 a' `  V2 T1 J       print qi=3;
" }! D7 w& a7 M- d; E: q9 I) R1 O) Bwhen Ci>701 and Ci<=1000 then, d* H3 i8 {! J8 U8 q4 y1 l
       print qi=4;
1 @4 ~4 m! Q* h( D) G! s% J3 ~when Ci>1001 and Ci<=2000 then* m) A9 G' r" C
       print qi=5;# n6 k* G5 x0 h2 s5 u  U- m
when Ci>2000 then  `8 D, e2 ~# t2 F, b+ K
       print qi=6
! {' P+ d) P. u4 uend;, b: I1 c9 R) H0 g
end;+ A: R) R# g# X; o9 M2 \

# v8 X* C3 g. W- ^  l. q          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
, m3 g/ t+ o4 z. A: l( A% m/ t' G          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:- R+ h3 p9 w# [3 w) E9 \
(number : integer)% b5 K7 ~; ~: i7 u
is8 ]) n+ i) I# N5 g* ^) b" g* q( I, ~
do( O7 |. `' M$ K$ V  U8 {
   inspect number) @  B: t$ J5 p) B) K# j
       when 1 then
: G) f8 y) G) ~. N+ G- x! L          print "not a prime number"$ T/ ^6 S: t/ t3 V
       when 2,5,7,3 then
2 \0 x6 t6 O; Y0 j. R: ]! T          print "prime number"/ P3 I; B& W. m; q) a
       when 9,4 then 8 a, g1 l8 a# ^% u  h
          print "square number"; V% M- s' @; C0 q
       else  V: g! N' d2 x
          print "no special number";
9 x# l, _* s/ u! }$ M          print "or number greater than 9";+ c; M& j* {4 O8 _
   end;1 g& V, U# ^) a. B( H7 [8 P' r2 k$ U
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, 2026-6-27 09:42 , Processed in 0.015793 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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