设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7458|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is; E$ `. w; v, I) Y% A
       Ci :integer; qi : integer- L1 c$ k; M1 [9 t4 N
do . Q4 `4 O; _+ F
       inspect Ci! R3 W& e: G- F- r9 ?; ?3 ?/ R
when Ci>0 and Ci <=150 then
8 ?6 P1 v$ s' X( A: B' P# F' c       print qi=1;9 P* t; q' k, K+ x7 W
when Ci>151 and Ci<=500 then9 a( A# k6 @% G3 ^' M' ?, R- j
       print qi=2;
& j1 y/ C% O: q1 Ywhen Ci>501 and Ci<=700 then+ G' n5 l6 ^# {, \
       print qi=3;
7 t8 r% o9 j, {0 k* I( t$ j4 nwhen Ci>701 and Ci<=1000 then
& ~$ e5 D. c: k5 S3 L9 v# Z2 V       print qi=4;
2 [8 `3 ?$ l  Hwhen Ci>1001 and Ci<=2000 then# m+ g7 E3 e+ `- ^9 g/ B5 _
       print qi=5;) }6 ]3 ~( X3 y/ ^
when Ci>2000 then
2 y% j2 p+ @- r9 F5 D% e       print qi=6
( L8 K1 \7 K6 P& _end;
( ]0 t: e5 K- H7 ^+ ]  h1 U8 r( ~end;
' |% E3 w- t' ]$ F
) k; k- E; l. r0 y! D1 G& q          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?+ ~+ E2 s5 ]" Y
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
9 }) V7 l1 `- F! a/ J* Y& j- Y(number : integer)( b. x, L+ m3 }7 u5 b7 s! P1 [
is& o: Y* u' H4 v4 J  w) ?
do
2 A' d4 b$ _: n; J. [9 _; a- M   inspect number9 I, Q# B3 t1 [! H4 p
       when 1 then 8 s  v' J+ W9 g* e3 a
          print "not a prime number"
: G8 Z6 X5 G* w: N. F       when 2,5,7,3 then , o& P' c3 M1 g8 A2 U
          print "prime number"2 d2 W3 A6 n- [7 \
       when 9,4 then 5 d0 f& y1 v  |* N% q! Y
          print "square number"2 y$ u$ \) C. X9 y  G
       else
* W! R" r) `* Z- E2 T& F: t          print "no special number";
% b" h; S/ D6 ?          print "or number greater than 9";
' `: r; \0 k# Q. \+ h1 `. j( _; X   end;
4 t8 r' J* A! |# U! ^2 V+ Wend;
 楼主| 发表于 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-11-27 14:49 , Processed in 0.021835 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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