设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7391|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
( c% t. H- g. u2 v1 L  Y* }       Ci :integer; qi : integer" ~. Q1 g$ s- J" S; _; Q8 s9 c
do 5 ]# d# U+ Q& n7 K  F3 }
       inspect Ci4 @2 ?& @7 G6 D9 i8 G3 ?9 ]) |
when Ci>0 and Ci <=150 then
; C4 r7 g9 ]/ I9 H       print qi=1;
- l2 G( @, [# z8 G3 ^( y' `when Ci>151 and Ci<=500 then1 B" D: b6 ^9 J( z4 l+ c* K5 Q& ~
       print qi=2;7 B' \9 b& V9 H
when Ci>501 and Ci<=700 then4 p) q: g' I. z& P4 B5 k
       print qi=3;: K$ t8 c8 q4 b/ w# t& |/ C) u
when Ci>701 and Ci<=1000 then: R2 R) m" l' d" ?" c% |
       print qi=4;
( n6 M. Q* \  W3 u& r- H- Awhen Ci>1001 and Ci<=2000 then/ K9 ?+ J5 T$ _& o) M" x3 T2 [
       print qi=5;
  c7 l8 G5 I7 t  y- [- Ywhen Ci>2000 then
7 t+ D' J. M0 s+ A' X1 n1 z8 r% ^       print qi=6
/ t: |: w+ E& ^& vend;) z* ~1 ~; P6 S( F7 r# e
end;: t; u4 H, T6 ~  s( C

+ x# k, K& l/ q5 r3 Z          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
, h4 `2 N+ C: _. A4 u' I          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:# A# [) n$ ^" @# E& s$ E# u
(number : integer)
# g. i% j; C, N! Pis
& h' Y# h) O: v* x  Xdo# ]" X: x7 x: N1 L3 M- ~& g
   inspect number
0 G3 U5 Z( k3 f5 u8 L$ e7 A6 d9 J       when 1 then
: `' q. s. q5 J9 e  R, s          print "not a prime number"
0 c6 [% G. S# O- ?       when 2,5,7,3 then
1 B- H" W7 W2 z# }& e          print "prime number"9 o3 Z; X; w& B9 k
       when 9,4 then + t( X! K, w# y- P
          print "square number"
7 d& y- S& P# n8 u: K- `! Q2 A       else
( g7 V2 k2 V. k7 N* ^          print "no special number";* o; d' T5 P& c/ A* T# j
          print "or number greater than 9";, [% k6 h) ~4 l$ u7 K2 e3 s; U8 e
   end;
) P  x& _( }, W  d% c6 Y# M# Q# @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, 2025-11-16 02:24 , Processed in 0.012996 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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