设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8662|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
+ f" R8 a0 Y, @4 x  h4 l       Ci :integer; qi : integer& I! G/ b/ d& F% x& e
do : h3 T% F3 u- _
       inspect Ci$ {2 O2 W7 Z- d# e/ L
when Ci>0 and Ci <=150 then
/ j2 M* C+ r  i* x       print qi=1;( N# x& J: ?) Q3 J4 O" m. n& g
when Ci>151 and Ci<=500 then
" g# j. b; o1 t4 {) u3 T3 H6 q$ D       print qi=2;* ^( t3 Y) G: O7 d1 B1 j
when Ci>501 and Ci<=700 then
, k. a! j% T; c* q: P4 u* ~4 J       print qi=3;
0 l) i3 M$ J  |, mwhen Ci>701 and Ci<=1000 then
+ Q: w/ G$ l, Y. h6 ?       print qi=4;
/ T9 d$ m4 ~- u. K5 Y- rwhen Ci>1001 and Ci<=2000 then$ D& H  J1 l( Y  ]( i& l4 Q+ {
       print qi=5;+ F$ y& E& H$ o
when Ci>2000 then
( ?! K* \; w. a# c( ?0 J& r% o       print qi=6
7 \4 }. k1 I; F$ gend;
1 n+ @4 ~( G  m# t! j7 R* ?% o' Rend;; A1 V9 v2 H; X* m/ S
5 o' [6 S) C8 `. t$ z. D9 r
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
$ k  t4 a9 T: y# i# k! j7 U          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
9 \0 ^' H! L0 z5 O3 S(number : integer)
4 ^) W+ q, b% m7 v# F$ gis, e/ y. _& u: B! J! T$ b) y
do" D/ h( I( E1 ?! W% K+ e) J
   inspect number
) f: F& |  H0 U; B7 Z       when 1 then
( V% \. x; M! O4 y! ]% V          print "not a prime number"% W, k2 _" M8 g; ]
       when 2,5,7,3 then   E/ K* U+ f8 x% M
          print "prime number"
1 Y9 G7 A0 _$ L$ H( o& T# `       when 9,4 then
* M% K( \9 y6 c3 y          print "square number"
2 _# |7 @% L) C) N       else; |% y# R* c* U: B+ ]
          print "no special number";9 a* T" W$ Z$ U) y
          print "or number greater than 9";
4 s1 \) R* C1 I4 k# @   end;
6 A* J' J! R; _( V3 x6 Q6 Yend;
 楼主| 发表于 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-6-2 08:02 , Processed in 0.011665 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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