设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9136|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
/ x! ?! U+ h) U& |- [% E       Ci :integer; qi : integer6 V8 X6 e, F# a& i  e8 x8 }/ _6 W
do
, n% V; `1 X" Y- |* l5 f       inspect Ci7 C9 {+ Y) d8 F6 @) J
when Ci>0 and Ci <=150 then " @% j: ~' M9 R3 P+ i
       print qi=1;
6 j+ ~3 o- {5 w4 m' t" E6 ~when Ci>151 and Ci<=500 then4 \# ]( h: g$ X( K7 [
       print qi=2;: y" Y# V! U- s6 I. m# a7 C
when Ci>501 and Ci<=700 then
5 p/ p5 Y% [& j6 n       print qi=3;0 S3 f2 k7 [6 u: b3 Z" P& K2 [
when Ci>701 and Ci<=1000 then" `9 p: Z/ h' l0 `% s% j5 H
       print qi=4;: d, H6 F  }* I/ b
when Ci>1001 and Ci<=2000 then% W; F; a. V* X& m& _
       print qi=5;
2 z' g) }  a) v( M6 a/ q/ swhen Ci>2000 then
6 B* N: w" G0 q) G       print qi=6+ \5 ?6 L$ e# E7 l  H' w
end;
+ U$ Z/ b6 J* ?end;
& e6 }5 ?2 Y; ^' i  g' v( P" s; y; k; _+ D& X# _2 F/ r
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?9 H% h6 Q: U% l) H' N, R
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:. {! E' N- x0 q+ Q, C
(number : integer)
! [$ `9 a" a# _" h5 a! S/ fis
3 e0 B; S/ P0 [5 w7 ?, Sdo5 e2 R% K1 P' }- n" G4 x$ z
   inspect number
& F) I5 v9 h9 A2 z       when 1 then % ?+ A/ a* V$ a2 l
          print "not a prime number"# T! x0 K# J2 a( _; S2 O
       when 2,5,7,3 then 2 E0 B3 w  R( I  H; `
          print "prime number"
9 O( J* S+ K" m5 ~3 Y" t# r5 v       when 9,4 then 5 j; i3 \4 l. W
          print "square number"! V! ]% R+ T% E$ S3 T  z0 z
       else
( o& \! B* R: p" }0 u. p( f          print "no special number";9 T4 i) E3 ?+ E2 ], x* d
          print "or number greater than 9";
. _: A; B0 c! C/ n/ S   end;
" e8 X1 u% J; |/ S1 B) send;
 楼主| 发表于 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-2 05:17 , Processed in 0.015862 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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