设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8652|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
! N8 q( A; L2 U       Ci :integer; qi : integer( n/ ]. t3 M2 t# U* o, t# J3 P4 o3 k
do ; h3 X) r* d# \& }! s
       inspect Ci
; D! i, S' h/ b9 y, F7 Awhen Ci>0 and Ci <=150 then
' u4 A% D& k. n8 Z       print qi=1;" S5 K2 V) E8 n. H1 h' D
when Ci>151 and Ci<=500 then5 j" P& p/ h  Q! I. z
       print qi=2;5 @1 B# [% W4 T& ?) ]; `  O
when Ci>501 and Ci<=700 then
" E% e6 E. ^5 W       print qi=3;; V; h, e1 G* R0 }! w+ j1 a
when Ci>701 and Ci<=1000 then
+ }# g' l- I) c; q" t( ?5 x7 {       print qi=4;
# w' k- z; m1 y  rwhen Ci>1001 and Ci<=2000 then
& L* K' h7 u% P$ h' }+ Q9 W       print qi=5;) P7 }4 l0 u; C( W2 Y% T9 s5 @8 t
when Ci>2000 then4 H: u6 c/ V1 g4 V
       print qi=6
, ]" L0 v, |0 Tend;' |8 Y* X3 l2 ^5 H8 R/ m* k
end;
7 C2 \/ V. i( J( ^
6 p& x+ `2 T7 s8 u0 m          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?4 G' @4 [* |* G% r: @
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:. P0 R$ \6 i) e0 [
(number : integer); X; Y, Y6 Z- d1 P# b  a
is
( K! [; |) v% p& G( r* m6 i1 vdo# S- C5 m0 u8 w5 C: V) l
   inspect number0 Z6 b1 i  V+ j5 u, D
       when 1 then " C, [. d8 G( n
          print "not a prime number"3 X7 ?% r6 [& y2 d+ }
       when 2,5,7,3 then
- D( o0 _9 w  B# V  k, A          print "prime number"$ x7 Q% `/ R, I* @) Z9 e
       when 9,4 then - W3 E0 i2 U/ D$ W5 P
          print "square number"8 b' b$ p& P" b# V) Y, n0 G6 f
       else
0 V4 |+ I' ]. i          print "no special number";
8 X) j0 J3 v3 u8 \          print "or number greater than 9";
; x" P% r) T3 l- q& w8 U   end;
% `. E; }* Y% s0 \. s. E! H# `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-5-31 04:09 , Processed in 0.019448 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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