设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7192|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
1 M6 o. t- ^9 Y# l       Ci :integer; qi : integer
  z% S4 I! [9 {' T1 N. mdo 9 I8 N; z0 S- H. ^7 C  a; I
       inspect Ci- X' K( ?8 Z1 z/ O2 P8 i! `- N
when Ci>0 and Ci <=150 then
; o/ f! y/ n7 S" p7 n3 N       print qi=1;! G7 n: V/ E0 s1 E/ `
when Ci>151 and Ci<=500 then
1 M6 M. K6 ]2 X% z, M       print qi=2;; q) n- ], f! l- s( A' }# i6 t
when Ci>501 and Ci<=700 then0 e1 j9 b2 ?5 {# T5 ~6 ~) X
       print qi=3;0 C. ^/ b. Z8 t- M( c5 o/ V
when Ci>701 and Ci<=1000 then/ x" }. x6 u5 R1 T
       print qi=4;% R7 S# V+ P4 A) Z5 l  G  m
when Ci>1001 and Ci<=2000 then9 k( z. J/ p$ q8 b' \1 o- N7 {, |
       print qi=5;
" @1 x3 {& X: Swhen Ci>2000 then
1 Z2 i. L# `/ K       print qi=6
+ x8 ]& r# g( t9 Gend;, L& z  ?% Y! q. Z. U
end;
, O8 Q7 a6 C# x9 u8 z( u, O8 {5 ?. U6 o4 a' g% ~) R0 n% W& o
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
* r5 u7 J- k7 m6 a" u: A- S          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:/ X/ G; d+ a% z  c( C
(number : integer)
6 N2 \6 q. M0 z9 Lis
( }; o1 s. H$ V3 `- |0 @do
8 I2 b3 q7 y! q, K   inspect number6 r$ `! h6 r5 _5 B$ S$ p8 H
       when 1 then ; K0 d9 G0 |. E1 }0 D% E6 m. h1 N
          print "not a prime number"2 `: s! @$ u: L5 ~9 M+ {0 |  I5 w: j
       when 2,5,7,3 then 8 w( R/ F/ ]7 N: |/ `" x
          print "prime number"
3 H6 \3 }$ c0 W2 ^  A% x9 u+ c7 c: C       when 9,4 then
) i- a; C8 P' L$ m' e0 ^0 `2 F          print "square number"
7 d/ o3 p, f, R1 v+ M# |4 c! a9 B! {       else. a$ }( ^- Z  C4 O& q) T' i
          print "no special number";
- h; J! _3 ?4 M! c2 M. i; m7 k          print "or number greater than 9";+ j& U& H7 Z4 e% q' q. f# F) J9 V8 b& M
   end;
( V5 Q% }( w5 U* q4 H* p; f8 R9 q2 w4 Rend;
 楼主| 发表于 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, 2025-10-17 19:12 , Processed in 0.015489 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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