设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7508|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
$ n0 ?& `1 K0 K2 f. d$ ]( P       Ci :integer; qi : integer3 v6 @; V% z1 q# p; f
do , b  Q3 g. H% C* ~- b* ^
       inspect Ci
8 ]& u5 {! g0 e  ~when Ci>0 and Ci <=150 then
% n9 \0 `. s4 O0 A3 u       print qi=1;# q" r1 {. @0 L/ Q9 F3 V' N# `
when Ci>151 and Ci<=500 then
  G6 a+ z8 `. U  d       print qi=2;
' J" N4 o6 t) K, w8 e2 |when Ci>501 and Ci<=700 then/ a- d  {0 I' B6 t
       print qi=3;
4 ?! c8 ]% W8 K% ?  Ewhen Ci>701 and Ci<=1000 then( I, |% P: w; o- z& I
       print qi=4;" V  i/ ]; e" [( e2 ~  {* X  |
when Ci>1001 and Ci<=2000 then5 a+ i! h. {1 y$ ~4 F
       print qi=5;8 R$ E; @# S4 Z% V5 p5 [
when Ci>2000 then# ], g1 g: N8 q  J- f' ^2 z
       print qi=63 a2 K: P5 ]) s9 g1 ]8 P1 Y3 e! A$ e
end;
& _$ W4 x$ x8 c( I) Fend;
1 f" w- n, L# a8 p' E8 g5 Y4 [4 r* _( f! a" k
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?% l7 k# i  b3 C3 V6 e; C+ r6 w
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:  ^. \) P% c2 ^6 \5 q
(number : integer)
# d/ A* t" C/ Z0 F! g4 H& d# Jis
- {7 M) h4 X  M! pdo
, y% U2 ]: N7 V$ h   inspect number
4 O( u3 z6 A5 N) ~: q0 F- @       when 1 then ) x) C9 B3 e6 _' K, N8 j3 q
          print "not a prime number"
/ F8 `  ?7 c% _1 m       when 2,5,7,3 then 9 e$ C5 }% |- M
          print "prime number"  o! Z( ?& A+ {' C6 s/ W
       when 9,4 then / e; w$ I4 O* I. L5 Y6 e
          print "square number"3 ]- F6 J8 B' K: Q: d7 F
       else& E: @1 S$ y/ C( z2 {
          print "no special number";# t7 i% O  M' }. \$ L% x
          print "or number greater than 9";
7 j6 d' u# t' F   end;
9 h! n$ Q6 W- b, O6 uend;
 楼主| 发表于 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 17:47 , Processed in 0.014005 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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