设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7922|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is1 Y8 R2 k0 U/ X6 J/ B
       Ci :integer; qi : integer
8 O/ Y# Z: x. z2 `$ g' W+ [2 edo " }6 n: D. H7 O, f. }' s
       inspect Ci
' j# h1 m& h1 x' C% z8 T8 k7 lwhen Ci>0 and Ci <=150 then
: [2 J: j7 Q9 {  t+ {- a2 `       print qi=1;
: p# ^/ L: j- Y* v9 K5 e  @1 X' Swhen Ci>151 and Ci<=500 then6 L+ c. j6 O! V+ Y* l
       print qi=2;
- K. \, m: @( q7 s+ i1 Hwhen Ci>501 and Ci<=700 then
' v+ y) J8 Q# }. F1 n/ W       print qi=3;
6 Z* l" M8 Q2 S  y. j, i: Twhen Ci>701 and Ci<=1000 then
) k( X1 e/ s1 x5 D0 _! n2 s3 q       print qi=4;
7 D4 T5 c) o6 y; F2 d7 e8 mwhen Ci>1001 and Ci<=2000 then8 {( J$ Y1 r0 g1 q* [8 O
       print qi=5;
) [; f1 s  }  k- z& t( Rwhen Ci>2000 then
, P# B& b$ k5 T* d       print qi=6, x1 z% O; [6 U* \$ j
end;9 }- `7 B! K6 f2 u) s: |) ?$ K# R
end;
, Y; s( [3 I) ^8 \9 P% n! H" Z. e5 x4 d! P+ a9 g6 L
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
$ b4 R& V+ U5 h/ U6 V8 R5 R# G          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
7 ?, ]5 q, U8 x- v3 o9 c1 w(number : integer), ]$ L$ q1 c% ^0 L( [7 ]% g# u
is
" r& o. }0 I* z; Kdo# N+ Q0 {# A. x1 q- I& q
   inspect number" B) k% m- x) E0 c# P
       when 1 then 2 V. H$ _; e/ s0 P: u
          print "not a prime number"
; Z# w6 ^3 o  ^       when 2,5,7,3 then
2 `) J& v5 |) Y! [0 b5 x" [; S& Z          print "prime number"( E$ K3 {) Z$ [
       when 9,4 then 8 W6 F" L* e: d6 _" \2 X+ U
          print "square number"
1 B" U* R/ }, I0 k/ S: n       else# K) k' `5 u: O, S0 I0 l. v, h+ r' a, u
          print "no special number";
, H/ V% D6 i7 K' c          print "or number greater than 9";1 d/ H6 h# @0 v# z' s" {% s
   end;
& c9 c7 |: W, kend;
 楼主| 发表于 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-2-13 22:43 , Processed in 0.013031 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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