设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8049|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is0 D& _8 I: G3 k" b, G* B8 b
       Ci :integer; qi : integer
3 g1 x, h% F! `1 n2 z/ Ydo
( Z2 ^# j7 c9 o7 s6 J       inspect Ci
& L, E8 D) K7 M4 T; r$ V$ ^9 Y' Iwhen Ci>0 and Ci <=150 then
7 S* L5 B, E6 S6 `/ Y       print qi=1;
6 l- Y! ]: e2 S5 E; s* h1 kwhen Ci>151 and Ci<=500 then8 V- e% ]* d8 g1 R3 @2 p( Y" _3 Y
       print qi=2;) O- b4 a- F2 ^0 r4 E
when Ci>501 and Ci<=700 then
: P" J8 i9 E4 K       print qi=3;! F* b) X& C3 Q# v( `9 U
when Ci>701 and Ci<=1000 then
# @6 K( d, r  x: |- Q% ^4 F6 `       print qi=4;1 Z: L& Z; P$ _3 k$ j" J
when Ci>1001 and Ci<=2000 then
( H* ?1 o& q( @5 ^) l6 h       print qi=5;
! [1 G2 J5 m' V7 t- Ewhen Ci>2000 then/ v& |* f( j5 u3 M, O3 Q5 x
       print qi=6$ {& i' `# E; w* G" @+ D
end;1 G. X7 }3 N3 \9 `0 M! B% P
end;
% d  f( `& F* y  F
0 `- d. m" J' C2 L) E% l6 W8 n3 W          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
2 G$ V  F# G& a' v. W          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
( o& [4 O7 m7 U2 f, ^" O) V(number : integer)3 J; g/ x  k% |' p' c1 X# g
is
  i7 Y* [+ _5 C% Kdo0 v: h6 K% u2 Z, E( w" r2 b! S
   inspect number
: P+ n  P" l2 W; C/ e       when 1 then
# j+ m$ ]; R: f0 n          print "not a prime number"( J7 H0 ^% Z& y1 v
       when 2,5,7,3 then & }/ \7 @: A- R  J% d, F7 V: J8 Q
          print "prime number"7 c- g0 C3 h  I; R$ p+ z+ x
       when 9,4 then . i# z9 ?, o( C
          print "square number": r8 u' O, V6 i* }4 N
       else  H4 Z& A6 u4 `: L  f
          print "no special number";
7 C1 J- Z: \3 w1 X: W          print "or number greater than 9";" c- D9 Z; M* r9 j
   end;5 r  V8 U+ `8 U& k
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-3-10 21:06 , Processed in 0.016606 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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