设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9319|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is+ A* k. U! F( `; I5 ~
       Ci :integer; qi : integer. {( G8 N9 w8 u9 n- J0 i, }
do * h9 Q* W( `* v2 @
       inspect Ci
( G* n$ r1 D' F, L4 vwhen Ci>0 and Ci <=150 then - Q, u" c9 l! l
       print qi=1;. d6 O: ^3 w/ N. y
when Ci>151 and Ci<=500 then
- g2 v& z* R+ T1 i5 i       print qi=2;
0 N* [' N- j! b, m9 |when Ci>501 and Ci<=700 then! |1 l% ^1 w" }# m# n7 G
       print qi=3;
. q7 D, h4 \' E  Hwhen Ci>701 and Ci<=1000 then3 T% f4 r' W1 u, j8 p+ b% I8 {
       print qi=4;% |' s: l" s& u
when Ci>1001 and Ci<=2000 then
5 p, \: E4 E) h+ V6 H% j. c       print qi=5;  o! G8 @( ]! N/ A9 ^3 c
when Ci>2000 then
" ~( A% u. W/ m7 X2 B1 P       print qi=6% T/ R9 o6 B( M- ?9 E
end;
6 s2 b8 ~2 M) C. t0 G4 {end;
9 A7 \/ Y0 i3 D3 n# v' u
8 P) }% F  f6 @6 I          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
9 d% x. P: }% ]  f0 u7 ^1 ]$ _          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:4 r: w* F! `8 f! s7 e
(number : integer)
( Q# v. U$ V9 j( b6 L1 I9 Vis/ j+ ^% m0 \$ z0 n
do" t; U# }, G$ l* A5 F4 U8 N
   inspect number4 \5 h6 x' ^2 [; ~1 X
       when 1 then * P$ O- t4 M  b! i% ]9 t3 X4 P
          print "not a prime number"
4 L( Q! y& @0 O( S       when 2,5,7,3 then 4 g9 F/ o8 W- A1 c
          print "prime number"
: _/ H9 u: Y3 ^- y: B* H9 M       when 9,4 then 4 f7 Z% r5 o/ j2 t7 X
          print "square number"2 I2 R7 D- h/ r
       else; u+ {- V" |! F% H" F; X
          print "no special number";
; A- Z5 p; u6 N: o, R4 e/ s8 f3 A          print "or number greater than 9";- y& S# z2 r( |: c
   end;: U2 X, Y; U0 H8 h
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-8-31 01:27 , Processed in 0.015721 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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