设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8589|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
4 B( |2 r* d1 C: F$ q" @0 W( s       Ci :integer; qi : integer$ \$ g7 W. ~/ E8 a" [8 f8 B
do 0 H5 O1 w% o( I" A& B
       inspect Ci
- }: G6 Q/ M3 Z5 Y; r  W; p& Gwhen Ci>0 and Ci <=150 then   V/ A2 ~, ^; B9 V: Z
       print qi=1;
2 N7 ]  Z. w3 [( a) X9 vwhen Ci>151 and Ci<=500 then+ z0 t- p8 b+ c+ s: U6 B
       print qi=2;5 `4 l3 ?6 f$ P; T4 x( L
when Ci>501 and Ci<=700 then
7 d6 L8 R/ d* c! j4 W/ M0 P       print qi=3;
( l6 X* D( e/ K9 Z! [when Ci>701 and Ci<=1000 then4 E; v2 r/ D) f& S6 w
       print qi=4;
7 Z, t3 \4 l8 i4 l- J" J6 |! Pwhen Ci>1001 and Ci<=2000 then' C1 Q; N  A4 }7 ^& _$ j  D
       print qi=5;/ q& a& M) u5 w: y+ J1 |  U) c& n
when Ci>2000 then
& N: Q) K1 a5 r2 G       print qi=6
* N/ B% r9 Y: D& ^end;9 b" w6 V- W  ~( F; s
end;
( m+ r; ?. g6 A/ B3 Q% s1 N2 M! P4 s2 h
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
2 S6 i, m! r3 U! y' h5 R          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:6 K; @2 P  ^& R  Q
(number : integer)
) q1 d6 b! k, N; h% kis7 p! [5 h  z2 ?" j% k
do! i+ N( B3 b' S
   inspect number
' o  t& x  {( D, l9 O* Q7 U) d6 ~+ }# v" [       when 1 then 2 G/ A1 e. l5 B: Y8 Q
          print "not a prime number"3 w; d: K: \) ^  A. c: U
       when 2,5,7,3 then / D# V& j3 `3 |$ z" O# B' a; w
          print "prime number"
! S8 j0 d# o* |( K* z+ L       when 9,4 then
) a4 B  ?7 `% K7 w! K          print "square number"
% v" P. [6 z5 `       else
" A, s- I$ T/ x+ F" H8 \0 [          print "no special number";" o3 }. u/ U& w, r3 o
          print "or number greater than 9";, Z) m7 S* M/ v8 S+ y, I& [+ l
   end;/ @# R7 m6 w; [6 M9 \
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-5-15 17:53 , Processed in 0.018991 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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