设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8744|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
* O7 c9 m! d$ `% W( H7 U3 |- {/ o3 z       Ci :integer; qi : integer
" }# W- s1 o) |4 Y! R, Ado ! S" L/ `8 e# w
       inspect Ci
8 X- a8 S8 \6 R- e: twhen Ci>0 and Ci <=150 then 9 @# G) q# N; w; E8 o$ I! Y
       print qi=1;4 k1 Y# D5 L( r- [
when Ci>151 and Ci<=500 then$ B0 i( W/ S" Q/ Z
       print qi=2;
# ?. c# k4 `, d& C3 H* s) uwhen Ci>501 and Ci<=700 then
$ a. E) s, L* D       print qi=3;
+ v) ~2 `; e# X$ @% Qwhen Ci>701 and Ci<=1000 then8 y, t2 R% e+ h  W* {& L
       print qi=4;! p& g4 N7 G+ f
when Ci>1001 and Ci<=2000 then
7 o. P' T  L$ f" g% M       print qi=5;
. C; t4 d- X) D6 H# b5 _when Ci>2000 then: H4 E8 Q( P2 g- r' A
       print qi=6
4 H6 @4 ^8 t2 _9 n* b2 zend;# O: h! {5 u; O8 g& Z5 B
end;: b$ p! H  m* i, O9 M& d6 C9 }
& T" C/ i3 z4 o; I8 h
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?: O% U( _/ l$ s* u9 T
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
0 q$ C% e# z. F! z# s  w+ C(number : integer)
7 |; l$ p0 g' f7 F- _is  Q' V% Z2 o5 |- t7 r+ {" l1 k
do
7 Z$ o* T. h3 s5 y0 `   inspect number) Q: A9 m& ?- n- q/ h
       when 1 then ! M: b) o+ s' ~1 s
          print "not a prime number"
# k9 d& e# f0 T; G* h       when 2,5,7,3 then ( r+ n) H5 Z8 J/ u
          print "prime number"
/ q" X" M; ]) |9 g" c' a       when 9,4 then + u( H) e) c9 x) M9 D6 d; s) K4 H
          print "square number"
0 |& g$ ~  Y9 Y       else
2 ]  H+ [6 W8 u7 L( G          print "no special number";! Z% I8 r1 o) |: q2 b0 |" t
          print "or number greater than 9";
% e4 N# a( j2 \6 B   end;/ \8 V- _0 I5 H% y5 y& y0 |2 M- q
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-21 04:26 , Processed in 0.012233 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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