设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8700|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is+ C6 w% o% ?) S. P  J" q1 _
       Ci :integer; qi : integer3 @# ~$ \  s8 t0 ~7 ?2 J
do # r# n$ W- E5 I# Y
       inspect Ci* x# h& ?" z1 }3 Q* e. F
when Ci>0 and Ci <=150 then 5 l, T+ ]" }3 s
       print qi=1;
# u( C8 j2 F9 y: w9 B% F. Z# A" dwhen Ci>151 and Ci<=500 then
8 J  a+ X& y" ^, z% O       print qi=2;
; J3 p% {9 D$ X4 _9 Qwhen Ci>501 and Ci<=700 then
# L4 W3 q* f6 x% o       print qi=3;
0 t8 `1 @& A: q  K7 `' ]5 y! Kwhen Ci>701 and Ci<=1000 then
" J: w7 V5 |1 t3 ]* o$ f       print qi=4;, P( J6 r9 r: L" a/ T2 _
when Ci>1001 and Ci<=2000 then  m- v$ E: N+ q- f8 ~
       print qi=5;/ r  f/ i7 L0 V! G/ L7 b
when Ci>2000 then! T4 ^" ]" _, i7 p9 y; O$ ~: c! h
       print qi=6, T$ c& r# M4 i
end;; x. i( c' s9 M4 \- _# v0 c: ~
end;  |- @/ J; n# v0 \5 s/ N
+ g# T  V' S% [2 P
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?! y4 c; B9 |& T1 O) s
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
2 @9 Z6 d; A* T" W(number : integer)
- s; a# @' W; Kis# ?: x" h! b3 e1 ~& |# m
do/ `; |, V. Z) U1 s
   inspect number2 m" D% c$ [1 Y
       when 1 then 9 B! }- H6 j3 \9 |; s0 R
          print "not a prime number"( N$ Q9 k( S* u7 C" Z8 P* x4 J
       when 2,5,7,3 then
. v% V1 k# u" }( l          print "prime number"
% [. G$ k; ~, h       when 9,4 then
* o* Y2 l! m4 v8 N, R+ s4 M. ?2 `8 k          print "square number"
4 k8 A8 v) L& h( V( y; y       else" q. H, O2 I! `; G. ]3 }
          print "no special number";5 X' v, t# a( J
          print "or number greater than 9";! U/ k* r6 z) |8 u" r4 |' K
   end;1 j5 P* k. o/ k% g( y3 A! {
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-11 23:11 , Processed in 0.011837 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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