设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7786|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
, ~6 @! _$ @2 y* [0 p9 q       Ci :integer; qi : integer. F3 i. b2 }1 P) n# S' S
do & S' r0 _' F8 S9 @5 D
       inspect Ci
. H* V3 H$ ^" nwhen Ci>0 and Ci <=150 then # \- N1 O4 @+ {- K' {  L
       print qi=1;
" S! d! ^* M: Y" zwhen Ci>151 and Ci<=500 then- M, Y4 q: a( u2 @
       print qi=2;
# M7 o5 @; _4 Zwhen Ci>501 and Ci<=700 then) U0 k6 B3 v* Q" S
       print qi=3;: D. d, w; g& L" O9 V
when Ci>701 and Ci<=1000 then& O+ \$ F2 b/ J8 [& B
       print qi=4;
' y$ W% a" e4 @$ Awhen Ci>1001 and Ci<=2000 then/ q" w3 ]$ s. N( P, o8 S
       print qi=5;
1 q' c) r1 S* W1 q/ T! l# [: Mwhen Ci>2000 then6 X. p" h9 B% z! ]$ X$ S- {4 U
       print qi=6
9 g) p; L( |* }+ \end;
$ n9 t) r' t: H- Bend;
. @6 c+ |9 k8 E+ U: K
2 ^6 s& r8 a+ d- @7 c$ e          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?/ d; s6 H2 Z0 C" L9 e6 X( d8 ?
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
8 i9 b  ~! p, j6 a(number : integer)
" O. }/ y/ m3 sis
  n+ ~: a1 u+ o6 l0 G% Vdo
9 a. {5 ^5 ^: Q2 a* F& Q   inspect number
* q$ B+ O: M8 O( {$ u       when 1 then
4 y; b4 Z6 E! Q+ Y4 Y( E          print "not a prime number"2 y8 `- a) X  [
       when 2,5,7,3 then ; v( T% p. |* p( F) b
          print "prime number"
- Q+ z4 g. C) P. R1 M       when 9,4 then 7 t4 M/ B" \* s7 e# Z
          print "square number"
- X; y5 T; i/ I: R% S, M5 _       else
# _  U& j' b4 B2 E5 u, N1 r          print "no special number";% D+ B5 A! V4 M
          print "or number greater than 9";
: ^: _; D3 \* d$ ]) B# J* c+ }   end;( I3 n) }0 E( w& K. t: i# M) Z
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-1-22 18:39 , Processed in 0.015763 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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