设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7504|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
* R0 u8 I: E, ?. |; ?0 X+ F) w0 }       Ci :integer; qi : integer
$ A5 o1 ~0 l- S8 A9 A: zdo
, A. q4 W- H4 U5 H       inspect Ci
# m/ {- N% ?- S3 n1 A7 m4 i6 kwhen Ci>0 and Ci <=150 then
% N9 V9 d7 N5 @* I2 u       print qi=1;  S% N8 z$ x( |
when Ci>151 and Ci<=500 then" m& |/ H) F5 f, X1 Z
       print qi=2;
0 ?$ P# s9 t3 `& w) s1 vwhen Ci>501 and Ci<=700 then
5 w' ~0 G, ^' [! Y3 ?& t  o: a       print qi=3;
7 B6 _" `1 K) o: H3 }& M1 xwhen Ci>701 and Ci<=1000 then
* {4 G; b$ k, W) t, L( s) o7 {% g       print qi=4;
! A" \( T% g7 B3 `4 x; twhen Ci>1001 and Ci<=2000 then
; E9 C. {1 v1 F! q: E3 _: n0 V       print qi=5;6 d2 y5 A  E0 r
when Ci>2000 then) L4 @: x- v5 b( q5 A0 h  |" x- n) U
       print qi=6
. a6 c2 T7 ]# ~+ t2 w+ U4 l/ m" {9 X3 Qend;) d- ?9 X9 \4 T
end;
" w2 F* M; q) o1 H! U7 R5 }/ l  h( ^0 e( A0 ?+ t0 J' X' X4 f+ Y
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
" M4 F$ i. `" m0 i          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:% K& c$ ?  `7 X* M" E
(number : integer)
6 S6 G9 V$ ~9 N% ?  @is
- Z7 v5 G# a. r$ Gdo  Z  W7 B( l) K, A5 X5 `, x6 i
   inspect number( L2 G) J% n3 _+ B; ~
       when 1 then
3 d; _1 T1 G( P          print "not a prime number"
2 o/ @: x, o0 V       when 2,5,7,3 then : y: E+ s/ w# k7 W: H7 Q1 k8 Y- }% ~
          print "prime number": o& a. [2 S  h; b8 G
       when 9,4 then $ k  D- S) A( Y% x( R
          print "square number"
9 B% p" Q) G! Y8 G; B9 C" v       else
% u- c! s7 f5 o0 v          print "no special number";
) l2 H5 u, m  c3 `9 g* m* ^          print "or number greater than 9";
9 Q( q2 t3 y% p$ S( E   end;
6 l3 ?' C' t6 R, k2 U/ 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, 2025-12-6 15:19 , Processed in 0.020579 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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