设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7733|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
7 ]9 o& ]) ^* G( A2 N       Ci :integer; qi : integer
% W$ @3 E6 }0 R' t- d# D* tdo   a2 i& ^$ }+ _+ D" B6 ~. T5 A
       inspect Ci
1 u! V2 u# \( I" |; nwhen Ci>0 and Ci <=150 then 5 u; o& M* F  S4 s5 T0 S
       print qi=1;+ ]  k3 y$ F3 P! k$ ?( V
when Ci>151 and Ci<=500 then" T% d2 [6 p: t  ~. A7 d. [, w
       print qi=2;
) l4 v) F; p$ h- v; V: H/ z0 Z5 j  ywhen Ci>501 and Ci<=700 then
/ n" D3 p1 P0 L& X9 }* Z6 K       print qi=3;
9 f3 x* o, L* S7 `! D7 z/ J( Rwhen Ci>701 and Ci<=1000 then
! a6 q; I- S2 P4 Z7 c       print qi=4;8 [/ R" m! B7 {1 o' L$ n# z! x
when Ci>1001 and Ci<=2000 then
2 N  r3 v/ D* Y+ q       print qi=5;5 h0 X4 V) K, S
when Ci>2000 then6 P+ d0 A! W  F8 z1 a5 B
       print qi=6
1 D5 m" ~& {8 J! m  n' Oend;
/ i4 f- K  k0 j8 V: w1 r% qend;
3 q+ q# C+ g4 x" I+ b5 r! x' c0 j$ N, p5 Q
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
1 R- F5 {( i0 d% q5 `          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
: Y8 H* o9 {7 N8 L: w(number : integer)
! W( N' w- p  M9 Q+ [is
: [3 T$ `1 O1 f- ?do* C4 L1 z9 p4 F7 U- B, C* Y9 E) R
   inspect number
( M. v5 N7 ~% G       when 1 then
6 G, k$ t' {7 N          print "not a prime number"; V( z+ g7 y; J4 r" U, W
       when 2,5,7,3 then
0 C: O3 b3 r5 y; r( \          print "prime number"
9 a8 z, E1 I1 G1 W$ q       when 9,4 then
1 S9 _* B! _" f* }$ V% t' V          print "square number", r, Z8 V5 I/ f+ r0 b
       else3 ^, Y! V( _1 i' G. G: f
          print "no special number";
9 y% v8 \, Q+ S8 N          print "or number greater than 9";
; `0 M$ c: a* o8 m   end;
& D4 T; s3 H. Eend;
 楼主| 发表于 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-1-16 07:54 , Processed in 0.021142 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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