设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8463|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
, k2 A7 V2 Y+ L8 j8 {+ u       Ci :integer; qi : integer: x; f& f% i; r+ I/ ~
do
& F  k- m0 H$ K       inspect Ci* O5 b2 y! C. L& H9 D' E$ z
when Ci>0 and Ci <=150 then & K' x! Y5 g" R7 _; k5 o
       print qi=1;
( P2 K! C2 x$ ^& Wwhen Ci>151 and Ci<=500 then
; ]8 H5 @5 y- y* a! r# B9 |0 B       print qi=2;
5 ~% d! H, o2 P0 @) jwhen Ci>501 and Ci<=700 then
4 v+ a8 [/ Y' {) L       print qi=3;* h2 ?3 |) f: m
when Ci>701 and Ci<=1000 then9 U/ u% O" q' ]; C9 ~
       print qi=4;8 E( W) y$ D) {& T+ E8 `; c3 c
when Ci>1001 and Ci<=2000 then) g7 j8 G) c) V: c
       print qi=5;
  Q6 @6 v: K' @0 `( Uwhen Ci>2000 then, J, S  j( F7 V" M
       print qi=6
" Z& k7 b, g) x' R: b: z3 K7 }2 Cend;
- F3 u% F8 T; w9 d9 ]end;, n7 V5 T2 }  e& `$ f. Z

. s2 e  _" N/ K          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?9 A' v6 ^2 N2 D
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
/ X* n, y1 }- }# i- i& A: x( c(number : integer)
& A1 M6 [. }7 f) dis
# ?  Z( e# i1 p( z9 ]do' L1 D. N* v, b9 q; V
   inspect number
! v: Q! X; e, W6 z9 Y9 Z! o       when 1 then 0 |' ^/ K$ X( b; ^; q
          print "not a prime number"' n2 a3 Q$ k  X- E: `
       when 2,5,7,3 then 4 Q7 D. r, K9 }/ V! J
          print "prime number"
  j% f8 ?# S% k9 y       when 9,4 then
9 V( U1 x* _; |& x. g2 Y! x. O          print "square number"
3 A& w2 h, b# Z1 \  Q9 F9 H7 E       else
/ o+ r) L$ X5 d, ]          print "no special number";
9 G% z# H2 i+ C" Z) P+ ~          print "or number greater than 9";. _6 ^1 ^4 G3 `' i
   end;
& n8 x& E; b, _- |7 e3 G" vend;
 楼主| 发表于 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-4-29 08:32 , Processed in 0.019253 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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