设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7742|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
9 G" y4 O  _1 u! f1 c9 j7 B  D8 W       Ci :integer; qi : integer( G5 [% Y, A8 y/ N
do 3 _1 S- k2 `  ?  C1 e) C8 }; V
       inspect Ci
7 Q. n3 x1 E9 F& uwhen Ci>0 and Ci <=150 then
8 F9 o- w$ Z& Q       print qi=1;
  X+ l8 W4 \, }when Ci>151 and Ci<=500 then1 Y  N6 Q" D" n+ n6 F6 w" g0 U4 A
       print qi=2;0 x& ^; {( N- K
when Ci>501 and Ci<=700 then$ Z: C. H8 ~) Y2 v# c& F
       print qi=3;
3 o" P5 @; U4 p4 i# y' wwhen Ci>701 and Ci<=1000 then2 n7 j7 z* _& t+ y8 g8 k
       print qi=4;
" h  T3 V+ ]: a+ d1 n1 w) f2 dwhen Ci>1001 and Ci<=2000 then! w1 H5 J0 d6 ~
       print qi=5;
! y* [6 g6 F6 K0 F2 p" i' |when Ci>2000 then
; N, R: N& G* s% `5 M' N5 o       print qi=6
6 X. h  O; n6 R9 v6 jend;; V9 x  T$ }* {" p, j0 h
end;
+ \& _2 J6 R; z' j& B& |. t3 A% U; \, g1 v
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?) A$ Z, s- T5 ?3 @5 c
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:2 z! M% \! B, r
(number : integer)
7 g0 h: x6 _, X3 Pis
2 V. K) G6 K' Ldo2 z9 E3 o; t+ _6 k* g
   inspect number
$ D8 t( S. [# ?( ~6 r1 e       when 1 then
$ K5 k: Y! x0 D6 z: B5 j+ [          print "not a prime number"% h* S: }7 Q8 B( ?! W* G3 a3 m
       when 2,5,7,3 then   M. z- U9 h9 T9 `* l' `
          print "prime number"
4 Y9 P, g4 @$ V) |* ~0 c0 e7 \* u       when 9,4 then
- ^9 {  b, B8 e          print "square number"
/ h- v) I- o% z, J/ X2 F2 W       else7 ~- i" k. G# b( V7 S2 f7 q
          print "no special number";
0 ~! Y& N7 ]+ O' D! A. V          print "or number greater than 9";# F7 G* }  j5 |; Z" R1 Z: y
   end;
0 I' Y3 B; T7 y4 Iend;
 楼主| 发表于 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-1-18 12:40 , Processed in 0.013220 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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