设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8448|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
! V* E# l8 G' N. a+ c       Ci :integer; qi : integer
  u6 ]9 g9 G5 N; ido 1 o6 S* _* y+ _3 N
       inspect Ci  l# w5 o/ Q4 k- t
when Ci>0 and Ci <=150 then
5 K) k( ^' _$ L9 a0 o       print qi=1;
6 g5 @, a7 A$ g& x! w3 u0 Nwhen Ci>151 and Ci<=500 then
5 f- h: F. ~8 p       print qi=2;9 ?. h$ s5 ?! _  l1 K
when Ci>501 and Ci<=700 then1 W6 s4 P& \3 g3 H" d
       print qi=3;6 d, k, V3 y! u1 W& e0 B' q
when Ci>701 and Ci<=1000 then# N% ?! B* z$ p  S' K" |3 o* ^" E
       print qi=4;! O- R' e8 N1 |% S; i/ N
when Ci>1001 and Ci<=2000 then
: u0 Y0 Z( `8 K       print qi=5;8 s* @6 B  q$ m( w
when Ci>2000 then
7 A+ F0 c1 E5 s$ p/ Z       print qi=6* H1 A- R: l+ u) L
end;
( @$ h7 O1 u' j% z* [end;# _% Z! \, g$ {1 s  \
/ }* f& M- g4 z" ]1 N3 H7 p+ Z
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?6 q$ J. U. ~. w* }. y: g8 w
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:8 ]5 H, ~. O6 ~* O. w* a
(number : integer)+ p8 f3 J' r; a; S; d5 h
is5 p/ e7 `: z3 o& o
do9 W/ ?" L, ~5 `. u& ]& Q
   inspect number
+ X; ?' ]' B- f8 W1 _       when 1 then + k3 E$ Y. @1 `$ l0 U7 l2 A
          print "not a prime number": `3 D* P. t! W5 s3 {0 ?1 P
       when 2,5,7,3 then
4 g  ]1 B# U5 \$ {; ]' r          print "prime number"# u7 c) ~% d+ s3 l: b1 s: G
       when 9,4 then $ I2 Q+ E2 V: d+ }% l5 c& ?/ d
          print "square number"' V- W' e7 s8 a: \" C
       else5 G% i4 b+ H) S4 j6 W+ I
          print "no special number";! N! t' `( B0 F7 d
          print "or number greater than 9";9 P9 l5 W0 m0 Y( t) _
   end;
# U1 v; x* a. ?0 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-4-27 20:33 , Processed in 0.014929 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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