设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6782|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
$ X4 H0 ?  P2 G& s* ]6 s& d       Ci :integer; qi : integer7 J2 ]- {1 o, _7 B1 D) }- }( u
do
( o9 ^/ u# X# @       inspect Ci7 c: g. t1 i0 t0 e% Y, `
when Ci>0 and Ci <=150 then ; z! _) d9 |# B% }8 y: {4 c
       print qi=1;
5 g0 e( p* {7 m% f+ Wwhen Ci>151 and Ci<=500 then, p! H3 @, G5 x) u& C2 K
       print qi=2;) e7 K* {# M9 g' e
when Ci>501 and Ci<=700 then
3 X& p2 ~, ^" `       print qi=3;* ?  C0 v8 C! S$ f" W( f9 H/ B
when Ci>701 and Ci<=1000 then6 {, ~# r5 h# Z" w: S+ _% [4 y
       print qi=4;+ N' p/ u, X, H! r2 c
when Ci>1001 and Ci<=2000 then
8 ^* k& K1 ^* }: J" a# V" g2 J+ x       print qi=5;
6 w! u7 I- k1 {when Ci>2000 then% |* Q& I7 h; ^5 U
       print qi=6
" I: [6 p4 V# f# O- tend;
6 c$ C+ j: {/ k5 o; Dend;+ x1 P5 b9 ^0 V; x% r7 y

" {  H: y3 @8 @( H' l( z          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?9 }; [3 W* Z4 t' N
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
7 n. k# j( g# q4 U2 l6 h  c(number : integer)
- S! e4 ^/ r0 R( ^. uis  b7 |9 \$ J" @& T* I' d
do# J3 D: ?/ M& s: |: |+ s
   inspect number$ {. S( U( f5 F6 j9 S/ q
       when 1 then * c/ D2 E+ M/ I  D, d2 l' |
          print "not a prime number"! l" Q: z  a1 I4 P9 [% C
       when 2,5,7,3 then
' ^5 Z5 N% C5 s6 L7 N; p          print "prime number"5 u4 C2 f1 e: _. J) {
       when 9,4 then & c, q9 J7 Q" d& z5 Z1 y
          print "square number"
/ b, y# m( q/ r       else
( b+ e1 Q: K# e0 @( [5 p, n8 d) D7 B3 K          print "no special number";
; ?% G9 F6 t; c* E2 M5 }: A" z          print "or number greater than 9";
9 X- L. y' N  @6 ^& u% B   end;0 ~: z2 y3 L& l0 f2 M0 y1 T* 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, 2025-8-22 05:01 , Processed in 0.013545 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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