设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7354|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
# `4 U% @8 H+ R; u% _/ [* J- U       Ci :integer; qi : integer
8 g, B7 w) q1 Z- m2 _* e* zdo
* d8 S  g7 D: |: ]8 g, u2 t* W       inspect Ci
5 {  x$ f. d5 R! p/ `: _/ R4 {when Ci>0 and Ci <=150 then ! v( n3 K7 `0 p; o) w9 i: I+ B
       print qi=1;
4 K; p& j) \7 O4 o* V4 b- l! `when Ci>151 and Ci<=500 then. |- q0 P3 I& n  M
       print qi=2;
7 P( A1 h4 b: I0 l3 E. K1 i# ]when Ci>501 and Ci<=700 then4 ^$ S; V# A2 z0 x. U, l0 `
       print qi=3;6 |. ?) Q( q7 \6 B/ g
when Ci>701 and Ci<=1000 then
# y$ U( O' t7 x& D9 P2 X       print qi=4;
+ Q/ F* K" G. swhen Ci>1001 and Ci<=2000 then
. ?1 ]! l" ]$ b) X' f0 k: a; K4 N0 H       print qi=5;) R( u" y. t5 ^  L
when Ci>2000 then
/ m! l& g  k6 ?" @( P* M* G       print qi=6
2 |: ]+ z4 D% a' K2 ^end;
7 y; Y! y$ p% jend;
7 M/ E& U. f# E( W; q9 k! d5 O+ w3 b& D. v# Q9 P* w+ b
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
+ c, [8 J% V; n5 b7 M          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
9 v, k; ~6 Q5 w, X- Z: @$ Y(number : integer)
; A* X! _! q0 i% @. xis0 L0 [, n0 g5 h) J7 K( ~. I1 W$ Y
do
7 |+ w( L8 x! o9 M: w2 x   inspect number& z' Q- [! ^9 q! }! K  y% o
       when 1 then - k* H" ~  M  u" I; \9 [# ]5 t
          print "not a prime number"
+ I6 L! s/ r8 P* F8 j4 W# D( A1 m       when 2,5,7,3 then ; R$ K6 U: h3 N& Z3 T; R2 o/ K
          print "prime number"
& n) T7 q0 g6 g2 i; F& x8 p       when 9,4 then % E  B6 o6 y+ L. B
          print "square number"8 B. L/ q8 E/ T2 E* h% d
       else% F& X. T1 g# G: H% L# ]5 J, s
          print "no special number";
; P$ g: w' X6 J          print "or number greater than 9";
$ G$ J" u2 ^4 L9 O   end;
! K+ y* c5 U9 u; `, h$ e0 I/ |, Zend;
 楼主| 发表于 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-11-11 23:33 , Processed in 0.016984 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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