设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7409|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is+ v0 [% m3 k2 [8 D0 }- D7 P
       Ci :integer; qi : integer
. e' z! t( {) z; n& sdo
* X; Y& @* O0 U  A. a' W1 C; m) j       inspect Ci
+ U9 Z& ^2 Y3 ^when Ci>0 and Ci <=150 then
, i8 J+ T6 L3 I) i2 Z' E       print qi=1;
4 x7 f" a" \2 N- fwhen Ci>151 and Ci<=500 then! T$ n: f" \- x. n+ z/ A) {& R: y
       print qi=2;
! P3 B/ D# a$ x. ?when Ci>501 and Ci<=700 then
: W+ o5 O; R# b7 R; {( s       print qi=3;& o# f3 s9 w2 P# P3 W* G
when Ci>701 and Ci<=1000 then* v8 N* D' n( n% x* b2 |* f
       print qi=4;
  U5 @6 M0 t* jwhen Ci>1001 and Ci<=2000 then
& C. `( Z! d$ C' S* ?3 E, X       print qi=5;
0 m$ e( S( p: {1 d+ p8 ]  Kwhen Ci>2000 then
$ X- i0 i& U' o9 P$ N       print qi=6$ g: E9 y1 P5 D  P6 j1 {
end;
. ~6 E5 B' G" wend;. H  l7 L' Y, ]2 i
. t1 y& B* w' R+ B3 Q
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
% c5 ^) q3 M3 c. K          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:9 x5 n  x9 |% Y7 h. E
(number : integer)0 f* @2 G7 D: g5 Q
is  A* N7 E  b* Y! y7 l* {" l1 i+ [* ~1 ^
do
5 a) s' h( g3 z  w5 q' q   inspect number  x) ~  h* ^! q" ?) r# `3 f
       when 1 then 8 g5 F# `+ c; r3 |7 K1 e
          print "not a prime number"" {5 e/ o' f4 z. y
       when 2,5,7,3 then , v3 f: T- v% C6 D2 l# {7 x
          print "prime number"% c* T) [3 Y4 |" D
       when 9,4 then 2 X# v0 \" u% t: x
          print "square number"
0 E- U9 R4 D& |% n       else
4 I5 n, B0 j8 n; F& w5 e+ _; l* |" V) x          print "no special number";
" @$ O4 b3 y# U1 V( u          print "or number greater than 9";0 X7 T0 v2 E, x, T" l
   end;
+ d0 q; A& \% G: Q* Bend;
 楼主| 发表于 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-18 23:27 , Processed in 0.018016 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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