设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6780|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
- b+ i  p$ O5 v+ w       Ci :integer; qi : integer& g. g! s5 z5 {  S2 k9 W* |( S
do ; h. j. u: F) h
       inspect Ci
& g# R) O; R! ^) s# M, j8 x8 }, o8 owhen Ci>0 and Ci <=150 then
( P3 w6 b7 [) ~- E  _& Y: {; P       print qi=1;
; T5 F+ Z. G; twhen Ci>151 and Ci<=500 then
! s; [9 c3 }% v% Q       print qi=2;
& y* o7 {! K/ i* f# kwhen Ci>501 and Ci<=700 then  N' }+ o, ?& l: w1 W/ c
       print qi=3;
& w* b! Q4 W1 b* n( Ywhen Ci>701 and Ci<=1000 then
+ F1 B# q5 K9 Y& W' w1 [6 g( A       print qi=4;
3 E$ ]" I- A8 {& z% U  Mwhen Ci>1001 and Ci<=2000 then. D% x; r/ }; N8 X/ R
       print qi=5;" ~, u. c. |9 S! x' l
when Ci>2000 then/ g! s; i& O; H2 X/ K1 ~
       print qi=6" c4 a5 W/ x' Z8 u
end;9 Q, E5 s* z. o
end;
& T; H( T4 W/ H0 `4 w- u
2 G. B0 A5 R  k          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
" x. v% u) t6 I% Z! W( M4 T          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:6 `( c2 M, E* r& G- V* Z
(number : integer)( {6 b( l- I2 g' \! \: f& X
is# y7 x+ Z$ o: I; @/ H
do
5 Q' Q' z/ S9 F# H% x  I8 D! I   inspect number
5 A8 f: S, @5 V- E" i; S0 U       when 1 then
% [$ }; t- Q, ^+ L' ?          print "not a prime number"
7 K$ N8 M! _. q' e) m       when 2,5,7,3 then # t' s5 k) _% ?1 q3 |
          print "prime number"! Z. v3 _" e6 S2 y8 L
       when 9,4 then
0 i- Q) m' n: \# N- u          print "square number": f7 U* ]: x# R5 \
       else+ s! |0 V' r* {! Z0 I
          print "no special number";) `$ D) h# j0 S0 z, N
          print "or number greater than 9";
+ ]5 o8 B8 E: {/ W   end;- m; K6 h* I8 t4 J, \6 M
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, 2025-8-22 04:59 , Processed in 0.013830 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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