设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7989|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
' [, Y% K" n, {       Ci :integer; qi : integer
4 W3 g% ^1 G  p( M, k5 fdo
0 V0 D: S- ^5 o# v, @       inspect Ci( n2 o) c9 I  |2 c
when Ci>0 and Ci <=150 then : d" [6 M+ j- k4 z7 c6 h
       print qi=1;
% j8 x/ P1 X# ?. G. \3 kwhen Ci>151 and Ci<=500 then8 X( U: u6 Q1 z. v# ^
       print qi=2;
7 Q# H7 @  G" v0 L. _9 |when Ci>501 and Ci<=700 then+ c" D) }1 ^' }% @& `
       print qi=3;- I: J" n3 I9 @* Z$ Q% G$ Q
when Ci>701 and Ci<=1000 then) h5 Z. a! @5 ]6 a: b- A. V
       print qi=4;
1 B6 @4 j7 a$ P0 Lwhen Ci>1001 and Ci<=2000 then
2 Q: C6 W3 O4 Z, t& e. m! `       print qi=5;) i2 R' k3 E; `3 ?
when Ci>2000 then
2 n. \- b% r$ {$ |( N       print qi=6
1 f; [4 E# u- Y5 q: R4 N$ T* C; Yend;/ J. f2 G& A0 [: @6 Z7 q$ E2 T4 Z
end;
  |3 H, q+ w( r; c: `% H1 [* y
1 N* X9 ?5 P( s6 [( B          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?" ~  N( G; g( ~+ w- O
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:5 f/ @( u, S4 n. ?2 t$ ^
(number : integer)
" B9 Z0 E- y" W3 e9 Kis0 ~0 s: o2 [. s8 Q3 f7 J0 {
do
% M0 @  E0 F% U   inspect number
0 G- b. Y& v6 O+ I       when 1 then
* K) f; ~, e. r6 j$ @( T4 O          print "not a prime number". f5 @, E" a$ v
       when 2,5,7,3 then
1 {1 o) |. E' r          print "prime number"* S- Z  m9 }8 ^/ c
       when 9,4 then
) U* @: [; f% i& T          print "square number"
; L, t/ Z# ?; z9 B) A       else
* {& U! W! _- x: d          print "no special number";
$ G" ?! z' d+ t' a) c. |          print "or number greater than 9";3 B) s/ L& A% L6 i* b
   end;
( J* z" V0 }; c. m( @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, 2026-2-26 21:23 , Processed in 0.013381 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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