设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9275|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
" r8 _4 C  `: b" Q       Ci :integer; qi : integer
  o& g- y- z: T! `: jdo
9 B0 w, _( g6 O/ W5 B5 R7 y       inspect Ci- L3 @4 \3 C$ p+ i
when Ci>0 and Ci <=150 then
4 g; d$ G: u5 F' n       print qi=1;2 g3 n8 C1 N9 l' m7 ~
when Ci>151 and Ci<=500 then
. M; a1 b8 e( w  N- h       print qi=2;
8 j0 Q) X8 i( W; b. \) p% K5 W$ {when Ci>501 and Ci<=700 then
7 G% b$ q& E9 g& N( z       print qi=3;$ w: u- O9 D8 S/ ~  M6 e# q
when Ci>701 and Ci<=1000 then
0 U1 \6 M+ w% x. s+ \       print qi=4;  |; L; H  j+ ~# X7 `: m8 P
when Ci>1001 and Ci<=2000 then" O* L, B+ \  q3 t
       print qi=5;& x: Y8 r$ Q- O7 y: v
when Ci>2000 then
  H+ g: h4 W9 j- a( v' f       print qi=6
5 T/ D; S# Y/ f! Y' R2 y1 y! yend;* r4 I/ B# p/ P  p
end;
0 [2 o" d- \# v
0 i. y- h" u- a: O" @; I- L          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
! ?" k/ b* d" ?1 E# A! ]+ V          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
, _; Q- ^( s/ c(number : integer)
$ m- ]/ k$ \2 y" O$ w$ zis" k+ _# p6 X  Z, C: @
do2 {$ b3 x0 {: K7 O* c$ W8 {7 L- \
   inspect number! F) ?8 {' Q1 j0 q
       when 1 then ' l  n+ I/ C9 D  X- e- `9 x
          print "not a prime number"7 U8 L. }( |" m. K; `
       when 2,5,7,3 then
2 i5 \  }; f9 |# U$ w8 q4 |          print "prime number"! o; H! e& G9 r7 I# v4 u& B6 f
       when 9,4 then ) A! w" n  W- K
          print "square number"5 M6 j, h% C- S, i" ]' ?
       else
" c; r6 K( Z2 K          print "no special number";
- E4 }; t$ Y4 [% W          print "or number greater than 9";2 t. b- C, T9 {2 ?) j
   end;. {- E  r& r9 ?5 I/ q( M
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-8-22 22:30 , Processed in 0.018262 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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