设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8904|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
0 f9 N5 z2 ^" i: M: q. N! W+ i       Ci :integer; qi : integer4 n2 N& w( g( O
do
; ~8 X4 y  _, a0 k! ]& K       inspect Ci
9 i# \# D" Q1 U/ `3 E3 Dwhen Ci>0 and Ci <=150 then
3 a; o( w) u- B       print qi=1;4 J$ x% M; T5 r. A1 R* V
when Ci>151 and Ci<=500 then! ^9 v: U$ G1 A3 D( S# x* j$ m+ I
       print qi=2;
3 y7 y' ^6 G8 f2 a' [when Ci>501 and Ci<=700 then
% N* W0 l9 U% Y: _8 J9 H- k+ S       print qi=3;% H0 q& B- [7 [, Y
when Ci>701 and Ci<=1000 then
$ j/ e& w# y  N# F, J/ N+ [, D       print qi=4;
, `4 w# e. L+ _when Ci>1001 and Ci<=2000 then3 b) [* W& U& M
       print qi=5;+ G- P9 H2 K; p$ G; H
when Ci>2000 then
& O# R; H. i' P2 N$ \       print qi=6( Z$ z$ Q* p$ u, C) R
end;
) X# d! ~$ M" T# t. w; G. r0 U2 s! yend;( s* S4 P" L8 \8 P8 w' W' U
! S1 X- h: b% E9 q
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?6 T: A, Y0 S! l+ x
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
  u$ P: L! A5 O# U(number : integer)
5 Z4 y% M- ]) S: qis9 X9 I& f% s6 U  t
do9 {, k9 J, a* h  K  P3 H
   inspect number
. x) N( j( {3 B       when 1 then
3 j! G/ P1 q  R, S          print "not a prime number"5 q6 i7 x1 e: ]$ i6 }! T
       when 2,5,7,3 then
. `. W& J9 V3 P% Q7 x4 E2 h% v+ y- W          print "prime number"7 }! j& u8 Y) B* l- h. [
       when 9,4 then + ]# ~6 O, T. |+ Z. d% k9 \4 ^( y' k) |& ?
          print "square number"6 A3 |! f! m  s- ~
       else
3 V# C6 M) e3 f, n          print "no special number";1 Q  D/ x' y4 X& H1 [
          print "or number greater than 9";
; x7 N+ q; F7 ^) |6 L) c   end;
2 e( p, w# Z+ ?" z! Cend;
 楼主| 发表于 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-14 21:14 , Processed in 0.016997 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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