设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8723|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
" a: j) a; c5 X- S- e$ f5 \7 b       Ci :integer; qi : integer
$ A: n6 y! O; ^! ^% Ido 8 a  R1 y" }; H) r8 U, U* n
       inspect Ci
: j& o  p6 J" h' V% pwhen Ci>0 and Ci <=150 then
2 R1 }# S; u  l6 Y$ t4 D7 u       print qi=1;8 g7 h9 h: C$ t5 q: D/ ]; y
when Ci>151 and Ci<=500 then' I+ h2 T+ K: Q- Y, e8 y. r
       print qi=2;
( k0 }4 R8 z, l7 V; Q# M) xwhen Ci>501 and Ci<=700 then
( `8 X( s2 X5 S. M" u5 b7 \       print qi=3;
, X. `0 z. M2 Y6 D1 B5 H( A: zwhen Ci>701 and Ci<=1000 then
. t  k- ~4 R- S0 D8 D0 N; O       print qi=4;- ~4 Y: @* v8 k. H+ \
when Ci>1001 and Ci<=2000 then
; q* D5 U7 K' ], e9 A       print qi=5;* n" `; ?$ _0 n0 }1 \" ^! n5 f
when Ci>2000 then
: O$ ]6 ]: g( S4 h+ x) u       print qi=63 x6 z# d9 v  [# c) _  n! s
end;6 B% b% }- \7 U, ~5 }" Q
end;
/ S" H/ U: V  F( a/ `8 @& {+ G% }8 v- O& `, c* s, k" Z
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
! |7 W1 ~8 D2 ^          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:. I; c( e3 T0 E: T" q; H
(number : integer)
* M6 d" m0 Z( a" M. S! nis
+ d+ a9 c- P; @; tdo
+ Q* c9 D* @5 T' k; e6 G   inspect number  H, }" P! q+ l+ l" c6 s( z. V
       when 1 then ' s* k6 Q, \' j$ f
          print "not a prime number"
$ E7 t: P. g7 P4 p! O       when 2,5,7,3 then
" w' [) s4 y* D9 ^% A! M: z; a          print "prime number"
" A! u5 N, F9 H       when 9,4 then 0 q/ e; M8 U0 [' W9 i( B
          print "square number"5 j  n0 V1 }% W9 p1 I6 ], L
       else8 w5 D: V( S( m$ p1 w; W7 z" L5 l6 N
          print "no special number";/ S: b' Q0 Y+ {
          print "or number greater than 9";
! p# o* x; F6 m8 t5 U   end;( b& T: a' `* ], {+ }2 Q
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-16 17:13 , Processed in 0.028275 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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