设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9186|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
& l' h' l8 l! e5 L       Ci :integer; qi : integer
; |  k& K% r& Tdo 1 V4 F2 o3 X3 E* ?  `/ W; s
       inspect Ci
: b: r* N/ G& wwhen Ci>0 and Ci <=150 then
5 E$ Z7 L5 I9 d0 g  ], Q       print qi=1;4 a- a+ h9 Q% e' u
when Ci>151 and Ci<=500 then
" d( [, T3 b( \' z( i) Q: L- O. T: e       print qi=2;
1 l/ u1 w. N, w- |$ gwhen Ci>501 and Ci<=700 then1 G/ B: w; D, U5 `
       print qi=3;7 |( C" p# f0 b' q$ M- i
when Ci>701 and Ci<=1000 then
6 `- Q5 r" e6 E9 a       print qi=4;
1 O; u* j$ I, @8 ~0 r9 M/ hwhen Ci>1001 and Ci<=2000 then% P/ l- y) B! d+ p
       print qi=5;  e7 y% X  W' n5 c% n; ~; c
when Ci>2000 then# D/ ]7 O+ ^- R" u& v
       print qi=6/ z% d. |% l4 m4 Q/ T( g" b: b+ \" ^
end;
* r$ W1 ^2 s. u: W* Eend;& H* w) ^) L% P% z2 s, ]. X

0 x% C1 F& D: D8 ]          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?! H; A8 i, l1 h% }* J
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
, x6 Z5 I! J4 [# M(number : integer)
! a& m7 W% a9 {$ v% c* {5 G+ k, X( Ois9 M! c7 \. @/ v/ b. p( S7 U6 A2 J
do
# ]9 a/ W$ v8 f% v' b+ v   inspect number
% F; @7 z3 @3 ~' I2 ]" \- C       when 1 then 7 T- F7 ?2 H' V4 @0 O7 X
          print "not a prime number"
/ o; e6 T# L$ a8 q       when 2,5,7,3 then
) P& b3 w4 j1 I% Y" m          print "prime number"
" p) Y: D, F4 s$ V3 Y' S+ l  v( x       when 9,4 then
0 D+ S1 M1 f7 i          print "square number"
9 g, }' G1 J! m5 |9 l  W0 V       else/ G# T7 {7 q; N3 g" H( v2 u" j
          print "no special number";% ]# r  b3 J# ?" D  M( i
          print "or number greater than 9";. _4 ^4 V3 s+ b/ m) l
   end;
$ |: M$ [. ^, v0 Zend;
 楼主| 发表于 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-8 16:11 , Processed in 0.013739 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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