设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9047|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
% T9 B' G; q9 ]* B- o       Ci :integer; qi : integer
- H  Q3 [- U, Qdo
  V& Y9 q& q, I! W4 w4 r5 Z8 W       inspect Ci
# v4 }2 [5 k2 W' v% Q' h4 U- uwhen Ci>0 and Ci <=150 then / W, n# L+ [3 e8 N
       print qi=1;
! ^2 B1 G: {/ B7 fwhen Ci>151 and Ci<=500 then
- `1 T1 q" L6 x0 t       print qi=2;
3 m  C/ I- p( u4 C7 ywhen Ci>501 and Ci<=700 then# ^2 o( w& V; e* [; s
       print qi=3;7 h% I% z( J/ m0 Y8 Y- i; o/ a
when Ci>701 and Ci<=1000 then
1 ?4 L1 n7 h# C       print qi=4;
7 t7 b  R1 z. ?3 owhen Ci>1001 and Ci<=2000 then
+ Z0 W5 O8 j  w- x       print qi=5;
# O( e. K$ I' Kwhen Ci>2000 then+ [- F0 z: j9 p' ^' P; {# {
       print qi=6
; B1 V0 ]9 @' d/ c- {# [end;# E8 i8 K5 x( I- `
end;- J' B, z  Z# \( _: d% G  E, X. k" c) ~

( y2 y) m/ C# F" Y" C9 i          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?) F2 d& H5 J* J3 d9 Y* S
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
. O/ ]( k* N+ P* q(number : integer)
( i7 m' c. W! q9 sis" s, U! ?" _; S( X- X7 l( n6 y
do
0 g8 {# _; o  G; v3 i. e+ @6 j& I   inspect number
3 d9 _- G, I/ ~8 \2 B       when 1 then
2 W9 \/ @/ [4 X0 ?% h$ ?5 Q3 V3 W          print "not a prime number"
6 X1 V4 p: G8 c$ e+ y3 m, @       when 2,5,7,3 then
: F$ K- I  R( U; s5 J$ q          print "prime number"( R1 e8 y& i  ]- k3 j
       when 9,4 then
9 G7 Y1 Y% q1 @" h          print "square number"
# _" \& {, _6 }" O       else
( }8 g; u: p  ]9 v1 k. s          print "no special number";
) Z% i8 C$ M! E* [; b" Z$ v          print "or number greater than 9";1 c' |, ^" g  M; V
   end;
3 N6 h7 J: f& y+ i' C# Dend;
 楼主| 发表于 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-25 19:14 , Processed in 0.011583 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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