设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9141|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
9 H/ [- `7 J6 R: I       Ci :integer; qi : integer0 T  a; _+ s( K" s& I/ U" r3 z
do
; c) M' ~, C" Q3 K) U       inspect Ci
% H* T4 D' ^0 uwhen Ci>0 and Ci <=150 then
& j8 J, T8 k: ^+ ^1 O& a* Q( _       print qi=1;) S! ~% |  f# [# d# w% @0 q! F" q
when Ci>151 and Ci<=500 then
6 d9 T" e3 ?& k' t# U% q- D       print qi=2;
% a, J- O. C* m, H3 pwhen Ci>501 and Ci<=700 then
/ f, O% Q5 ~# ~2 s       print qi=3;5 l0 i' Y: }0 ^( H
when Ci>701 and Ci<=1000 then- l/ o! j) `. H
       print qi=4;  m' k7 ^8 l! Y( v$ X
when Ci>1001 and Ci<=2000 then
$ `# L8 e* O9 t4 P: E8 e; D) o       print qi=5;$ {, Y1 R7 U; m) f4 x3 g
when Ci>2000 then
" y# \8 C5 F' l       print qi=6- [6 C1 E- Q, ^/ H5 [
end;% V5 G7 J2 [, v+ L. D8 F" ^
end;
% a7 h/ z( V. g3 l# F
  W6 [7 {" C" ~( d. o% {          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?  ]: P- m+ Z. ?: [
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
7 e" I% h$ d- y+ n' F4 N(number : integer)
. b6 t) D9 H# tis
' L3 h  _" v: {( ?2 E5 ddo
$ ?' |, r/ S1 c% L$ m) X   inspect number
6 y) s5 n; G0 y       when 1 then , R8 Y( W  `: a* @) [% T
          print "not a prime number"
( E+ m  [. ~6 R4 P$ p. i+ S5 ~       when 2,5,7,3 then   w- P! ^+ U, z* {. C, ^
          print "prime number"
; V/ U* f3 a" X5 E2 d       when 9,4 then
. u; M. ]$ U9 i% Q          print "square number"/ L% n" g3 F) U: B
       else
( ~( U/ ~" ~' ^' M          print "no special number";
* D+ L' T  f8 I2 U          print "or number greater than 9";
1 H8 R8 B( C$ g   end;/ m/ J; Z' p. ^
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-8-3 12:33 , Processed in 0.015448 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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