设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8066|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is/ @* O+ J0 [& L
       Ci :integer; qi : integer
% d, Z# T% z1 Q% P' e$ A/ tdo : z$ h3 m- S! |# S; l
       inspect Ci
: ?0 F6 \$ ^1 c+ b' G$ f5 g; K: Q+ E4 awhen Ci>0 and Ci <=150 then $ _. \. y, [  p
       print qi=1;
% n3 W0 l- K5 ^when Ci>151 and Ci<=500 then3 o. R! ~9 j, B! D# Y' R' w9 p; s
       print qi=2;( F! U. O+ |( l$ s. b5 \
when Ci>501 and Ci<=700 then
" P1 O9 a" I, x7 F       print qi=3;
7 t) k- N6 [! ?; j! p( Hwhen Ci>701 and Ci<=1000 then
( P9 H9 i, E6 K/ s7 ~9 W       print qi=4;
: ~$ P% L4 [/ i! B# u3 k4 awhen Ci>1001 and Ci<=2000 then
+ P4 M" h' K6 g+ X5 a       print qi=5;
) y) H" `- {& @8 i; f* a  `when Ci>2000 then8 {/ a# ~& Z2 d( T& N2 D
       print qi=6
7 O4 i, W( s/ R# i, M# H, u$ a# ?* V0 uend;
3 M  O( a/ m; q+ i# l* wend;
) H; d( X: b5 e- o2 P7 [
8 {* v- j. \' a. R% v1 c          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?6 E+ c8 V1 r/ M4 Z9 m! n! a
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:! J4 t; Y3 Q6 @$ q
(number : integer)4 a1 _: J9 |! o7 k% a% B% U& p8 u
is
9 @$ ?/ g, |3 s2 e. x# b" J: Ido
( Z0 q' @& O1 v' q   inspect number6 f& }7 j8 T+ X$ a5 B6 D6 _
       when 1 then
2 Z& m0 k+ h% ^# d5 e          print "not a prime number"" q- ^' l  p1 N# A
       when 2,5,7,3 then 7 l6 D0 m9 o, W3 n+ _* u& {$ I
          print "prime number"& m. a, k+ Z! o: n1 r. s. S# d% q, M
       when 9,4 then % T& a. W/ f4 P! j1 u8 a: p/ u
          print "square number"
  z3 s/ V( e  x5 I% K# F, Z       else& _- W7 i$ J3 j- M
          print "no special number";
$ b/ p5 R( s5 D          print "or number greater than 9";
: s0 _/ e- \  t# R   end;
; k$ a8 |, R2 }9 t  D7 Xend;
 楼主| 发表于 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-3-14 05:36 , Processed in 0.018064 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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