设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8948|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
( P4 ?# P4 ?- s: `' S. D2 l       Ci :integer; qi : integer
/ i( f( a0 I3 F% t. y) Ndo
$ |1 s2 U9 g5 X8 ?  |: \; D" Z       inspect Ci( N- `+ e0 l+ D! x" t
when Ci>0 and Ci <=150 then
' U7 {% U4 G4 F( g; k' [1 D/ R6 L       print qi=1;7 I5 v4 ~7 C, w* b$ K4 O% c: n
when Ci>151 and Ci<=500 then
0 T( g* k5 A" y1 S3 Z+ U0 C1 d       print qi=2;1 _6 \& O6 s( g
when Ci>501 and Ci<=700 then2 x8 K7 @3 E% f; C9 d4 b! r$ k
       print qi=3;
8 W, I4 o. b, `when Ci>701 and Ci<=1000 then
: Q% j0 m. [- H. @       print qi=4;4 z) }  ^9 }6 S4 j7 g, N8 Q# i4 c2 g
when Ci>1001 and Ci<=2000 then! |. B0 H7 L/ U  B! H% Z( E4 ^1 e
       print qi=5;
9 v6 |# p; e+ o( w, U- Owhen Ci>2000 then
8 G% h5 D4 r2 J2 O2 \       print qi=6
% {0 i* F$ ^' l% O2 Tend;$ K) I8 {8 S1 O: \. T; e
end;
" e- Z- T% [7 j, y
1 ]4 u) A- C8 G2 P6 h" K          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?8 M; x7 `4 V" }
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:! x$ G. ?, S5 W; [$ R" U# S
(number : integer)( N8 ?# A9 O  {& K; M# B: z8 a, `
is& P' N2 ]8 K4 k
do0 m6 F- g: ^4 v  W2 Z( W
   inspect number
3 q9 d, ^/ c1 c       when 1 then
7 h- W9 c& s) ^- B7 L          print "not a prime number", F( G7 Z, Q: U- _
       when 2,5,7,3 then
  v$ _* p* ]' G  E, B          print "prime number"
8 m& [& i9 U# I% E! o! _       when 9,4 then 6 {1 |  _6 @) K% X, g8 f
          print "square number"
' S8 D; f7 V# i9 ]! V5 P       else
! g+ C# n1 m0 t; N/ d8 b3 q0 G          print "no special number";! `/ y8 _2 s+ b$ Y" Z" Z
          print "or number greater than 9";
2 `6 S% n1 H, t, u4 S5 v4 ]/ ^: H   end;! S4 ?8 Y3 ^% M& E3 t
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-7-18 10:12 , Processed in 0.013219 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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