设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7655|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
* N) B4 W6 l- d: ~# U  L; V       Ci :integer; qi : integer9 _% W7 b8 F" j9 C
do % N& z# o% i: ^
       inspect Ci
* c3 I1 o: |7 N. v9 z( J+ W5 ^when Ci>0 and Ci <=150 then
/ g3 ]5 c/ z9 ?; N       print qi=1;
4 \0 C8 R8 W5 J3 D7 b; _0 Xwhen Ci>151 and Ci<=500 then
0 Q$ z# n3 e2 \7 x       print qi=2;
( u* O4 e/ M) v+ u* Dwhen Ci>501 and Ci<=700 then. j& b1 S; n* Q3 b  W! l2 [
       print qi=3;# a' d5 p$ `8 l+ ~
when Ci>701 and Ci<=1000 then
) A0 }& Z: H2 w       print qi=4;
% @9 ^+ d7 ?6 i' W1 _4 |9 }) l' rwhen Ci>1001 and Ci<=2000 then) e7 g* A+ }0 r' ]
       print qi=5;
& a# |: i+ T( u- z2 d6 y  Owhen Ci>2000 then
% H3 g) e; K% u, l( q. h$ T  E* E       print qi=6* {$ K; U* n. x  ^/ S7 e# w$ _; T8 X
end;3 D  Z+ Z# X+ Q9 s0 U# V
end;
& O' i+ {0 a# R6 ]9 S  S+ X6 r, |, n3 Q/ N; O0 T9 z1 X' |6 v
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
+ Q. ^" A3 _1 `9 L! e0 D2 x; Q          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:/ S5 D+ ~* x  }$ R) j8 B8 q
(number : integer)+ u( R# c. o- c; e: A3 q7 p
is7 t6 ?4 P1 W; p% m: M
do/ f4 c3 `, W. W% A# j
   inspect number3 ?  b, n) p7 t" ~/ |% E3 A# C
       when 1 then ! \6 L6 H, {/ ]
          print "not a prime number"
7 o3 h* d/ Z; _8 s       when 2,5,7,3 then : c% q) Z% e4 x& d/ N1 `4 P* Q
          print "prime number"
9 `4 |* H7 m( N$ s$ n) ^# u6 s       when 9,4 then - z2 P9 p0 p/ N8 K7 ?
          print "square number"
; s# _0 g! y1 @* @0 W# [( C7 a" V       else# w0 [1 m) z& Q5 o3 f: W
          print "no special number";
- C# h( {2 C0 i& g+ |5 o. _  y          print "or number greater than 9";
% R/ `* R  P2 L8 M   end;
2 E9 P6 p# f% P- F- K- w: S2 @7 @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-12-24 17:52 , Processed in 0.015098 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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