设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8342|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
4 [- G) I2 ^3 n+ Y- t       Ci :integer; qi : integer
& p$ C( `3 Z) G8 W4 [do
% _9 }/ q; n+ _* t  A7 I       inspect Ci
: g" i$ |# y0 v: ~, ywhen Ci>0 and Ci <=150 then & x4 W9 q3 v8 Z2 H" |4 \
       print qi=1;, T: o7 o7 I1 W9 x
when Ci>151 and Ci<=500 then
7 ~9 e! m. z/ i/ u. x, B; Z       print qi=2;/ ?2 A7 ^! K! _  |* z8 }( ?- [- B; B
when Ci>501 and Ci<=700 then; F3 d2 ?) x8 O0 z0 Z
       print qi=3;
( u& ~/ g  Y1 G7 g! W! Q  dwhen Ci>701 and Ci<=1000 then
  X8 [  j4 O, L; W$ A/ E8 Q       print qi=4;3 d) J  ^- Z6 D( p% o2 R% K: \' G
when Ci>1001 and Ci<=2000 then
" _9 n' `8 N" ~9 a       print qi=5;
" p- z) Z' E1 O' Iwhen Ci>2000 then
$ _5 i  w5 N: R: ?. d" [4 U       print qi=6
  C, B5 M8 b5 U. q/ s; {; Bend;
4 I9 N' l5 p$ Q" Lend;* w2 M: c/ i8 @' D

7 ^/ i# I5 g4 _  ^$ g4 Y* H          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
- ~  Z. g  C  K' B9 @          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
- ]8 G$ {1 W) A2 L, e+ S9 X1 u(number : integer)
& Q$ M0 q* X' n* P/ _is
7 \' M, Q8 K% L9 U- [- W, C+ X& Edo" w; D# O( `3 k+ f( x% d
   inspect number: ]1 k5 q/ A9 M0 D8 e
       when 1 then
) C: c" X) a* v0 v          print "not a prime number"  ^$ c0 \: n9 A+ Y* z
       when 2,5,7,3 then
  W$ L* [. L6 j' I8 m; m          print "prime number"
! d$ X' E0 o+ h: v* ?' y       when 9,4 then ) R3 H$ a7 q& d% z  A$ D: K. s" [
          print "square number"
3 P3 C9 k# m% |" ?! p5 ~       else2 g% S4 E4 W5 I( G: B2 n
          print "no special number";
$ p4 x+ i: W/ Y          print "or number greater than 9";/ A5 J1 u: b8 K8 G
   end;
- p7 l" f5 f5 X* wend;
 楼主| 发表于 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-4-19 14:27 , Processed in 0.013373 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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