设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7988|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
) w8 a" l# x7 s- @; v2 Z* u       Ci :integer; qi : integer9 P4 u9 `3 g8 ?* F0 Z
do
3 p4 q4 x1 Q8 ~2 H$ j       inspect Ci: b- s( B3 U( J6 E7 J
when Ci>0 and Ci <=150 then
/ F1 I9 x& T' x% J       print qi=1;
4 ]5 T  _6 q1 L$ N/ ~$ }when Ci>151 and Ci<=500 then
0 X/ c& C5 t  i! E       print qi=2;0 V. F2 I4 y; _
when Ci>501 and Ci<=700 then
1 H+ A( {! M2 m" G1 |9 L6 N3 K5 F       print qi=3;
4 G4 I) v% w7 \0 M* |when Ci>701 and Ci<=1000 then
" n( k7 I1 c' P: o/ m       print qi=4;
+ ^6 h: `' ^7 l1 kwhen Ci>1001 and Ci<=2000 then
. K8 B4 p# F; E$ L3 o0 D       print qi=5;( ?# g. ^7 p1 i
when Ci>2000 then3 s' d3 T7 B% i* O: x# i
       print qi=6( i  ~( ?" d# U+ T( S' H
end;4 ^4 \1 [  }: I% z# z: R
end;
* e( |/ D+ A' s; g* U
" v6 l: x. q2 f+ H! W# X          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
- Y  z* |/ U# ^/ @          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
" q8 \8 w3 z1 z( M% B5 e9 ~' w(number : integer); N) [0 j  L& g
is" b& F  |5 w% b; Z6 |
do
* b+ W4 h4 t: X9 m3 n   inspect number
* w. {( L9 p  z! I4 a       when 1 then
7 |/ ]' V, ^- [! _7 \' _, h0 r5 i  V- b4 z          print "not a prime number"
# `9 |/ z+ s, J( F2 B6 t       when 2,5,7,3 then
3 A% A3 h$ n. T) s1 D4 Q5 B          print "prime number"( z8 E7 _3 n9 u/ i3 q! L1 z
       when 9,4 then
* }2 v% @2 R4 j5 a# E          print "square number"
$ I& M! Q1 b6 d6 |5 z       else3 t- r0 R5 }  }. l5 T# _
          print "no special number";
& O9 T9 F: U' c0 @& v+ \2 m  Y          print "or number greater than 9";
9 I$ K$ E6 b: Q; C   end;& S5 T$ }8 V3 e
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-2-26 21:03 , Processed in 0.014818 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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