设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8255|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is; T  \7 h: G4 U& x  a; o: g: T
       Ci :integer; qi : integer
6 E& ^$ v8 X. T  m) Fdo : q# }6 x* t- ~; D1 P  ~
       inspect Ci
, i, g6 j& H. S# h1 x2 awhen Ci>0 and Ci <=150 then
+ M7 M  L+ u% R- z! G       print qi=1;+ m+ \5 _- K6 q% d. Q, [
when Ci>151 and Ci<=500 then3 v  t8 f/ C9 j( z) Y5 V
       print qi=2;8 Z4 X& @/ ]* A8 i6 y( y
when Ci>501 and Ci<=700 then
) M& m, v+ f+ `$ h( ^; r       print qi=3;
3 ~2 g% P5 E7 ?# o2 H" y3 C( hwhen Ci>701 and Ci<=1000 then
4 X. o6 H, z7 ~3 P1 v       print qi=4;1 ]1 Y2 Y, {+ I! N
when Ci>1001 and Ci<=2000 then
/ |+ K1 ^  {6 a1 K" W! J: [       print qi=5;
' {% b4 [  Y7 s3 M) Ywhen Ci>2000 then
9 O, r0 Z. R  _. X. a       print qi=6' s$ V! y' `6 |; [
end;7 `% j! r' U7 X8 [
end;* x; V% K& X" r) P9 d  l7 x9 `
6 b6 V$ \  c3 J2 q. a5 _+ V! b
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
5 D4 A' {  J$ c- T( e) e  A2 _9 X          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
6 O" m4 H2 z' z(number : integer)" S  {" u$ h* ?  g3 w
is
& Z- E. k# ]! p5 J6 _2 a0 Ydo; A% ?- c7 ?( V5 i# I, j' l
   inspect number: C7 K. S1 M3 q
       when 1 then
8 R. y: g( C! u9 }          print "not a prime number"/ h( X- k# y6 o/ |5 ?' c$ _' K
       when 2,5,7,3 then 1 d+ n7 z; `+ z+ F8 E1 u, k
          print "prime number"% \3 Y9 e& y" {
       when 9,4 then
' a3 `2 j  m5 I8 I          print "square number"* m. t( w# i1 |! m' O+ @: D; u
       else$ m6 q) Y) t1 g( U
          print "no special number";! G4 t5 M! h) p7 G. b
          print "or number greater than 9";
/ n. }8 l6 A5 f" h! g/ l* p   end;1 }3 @0 T; a' b$ U4 F+ z) a! j9 H7 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-4-9 06:41 , Processed in 0.016182 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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