设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8824|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is- C8 S% Y4 B0 A6 p+ i0 m+ A! l
       Ci :integer; qi : integer
2 f! m7 Z  u, }do
( e' Q. a/ d) ]+ e       inspect Ci
, K1 W# t& O" o9 @when Ci>0 and Ci <=150 then 2 u( I# P' L$ m, D- O& l
       print qi=1;
1 Q9 h$ f: {  ]  k0 X. q; _when Ci>151 and Ci<=500 then
$ n& i, f& F6 E1 `. }7 `. i  ?& k       print qi=2;& j3 C8 r' ^# @8 R  p
when Ci>501 and Ci<=700 then& _% T% A2 W8 h8 i% |/ h
       print qi=3;
: x# l9 g0 F1 ?( Rwhen Ci>701 and Ci<=1000 then
5 J4 f& i3 N& F       print qi=4;1 L/ U7 k" p3 v; |. V; {
when Ci>1001 and Ci<=2000 then  |% p, c6 t2 \+ F- n6 C, C3 Y- `$ O1 [
       print qi=5;3 k4 }7 Q9 o9 R# J
when Ci>2000 then6 F# n* N; I7 D' a$ K5 [' J
       print qi=64 A& O6 |; y; {& z! y7 ^3 ?
end;* e- j$ n2 _  `6 j2 J6 [
end;; g8 e+ h0 n9 d# ~. [6 O+ w
: g1 ?3 `, m. X, \5 O3 q- R. u
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?- d: G/ @% m, b3 B/ E: N/ R2 M# N
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:6 ?" c/ p/ ]1 C  ]; Q- s
(number : integer)
* V5 S; y# _  |( x. Ris# L; V6 Y, c4 S
do' R# v4 c$ Z$ |+ j3 e8 |! _- B
   inspect number% ]7 P0 b7 r* v0 c! t3 X
       when 1 then & B$ y; ~8 V, B* j/ G8 ]/ T
          print "not a prime number", j$ ]: A2 X; _) S& y. \0 y
       when 2,5,7,3 then / K) y) k  }3 k3 I
          print "prime number": M. m* c/ R6 C2 }" u) h+ U' E
       when 9,4 then . x. S$ q( {* N3 m9 r; ?
          print "square number"
9 r$ ?- }+ [* n8 s       else- v7 q( W1 r) _4 L- ?
          print "no special number";
/ t3 n- g1 c* o# y9 P          print "or number greater than 9";$ x: l7 ?7 E% V0 _& @
   end;
4 [* B& {0 L) t- e* [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-7-7 18:07 , Processed in 0.012965 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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