设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8139|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
2 Y0 K: K. v; ?5 y% b+ b       Ci :integer; qi : integer% l$ i8 f$ o$ ^) F$ g+ Y  {$ G4 I1 @
do
' g1 {7 I6 Z/ l8 p3 P: M       inspect Ci
3 k* ?" J8 u5 q" H) [when Ci>0 and Ci <=150 then : P+ e+ e9 h, T) ?) @
       print qi=1;
- Q% k3 ?3 ~2 [, G; @when Ci>151 and Ci<=500 then
8 U- G) n  B& w" @6 \       print qi=2;7 L! h7 [* T6 S9 r+ V" L9 M" B
when Ci>501 and Ci<=700 then: @( i7 b' p/ P' z( D: P4 F
       print qi=3;
, q8 Y9 x6 r6 _2 B+ o5 iwhen Ci>701 and Ci<=1000 then
% R0 x3 f. E( {4 L0 p7 i" t       print qi=4;
4 p) r4 ], S* V) M" Rwhen Ci>1001 and Ci<=2000 then: A/ @& p/ G" u" F. s( ?
       print qi=5;
. l  K7 c  N5 H; r$ gwhen Ci>2000 then( ?& Y: y1 }& U5 i0 z
       print qi=6
2 O  D" X* {4 j  e! {7 ?end;
* ]5 X- j* E  y3 }3 o& rend;% h! P9 E  D( F3 O- W7 Z$ z

# j- O, h- r; a# l4 S5 Z) P& p+ h          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?) I$ K5 {* G1 Y/ z$ ~! [, w! u
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
0 `0 Y. u! L/ ?3 e1 D  [(number : integer)
  c4 U" Q" Y; n3 y7 _8 G1 J6 `is- s$ y* N* W; j; t; M: r
do; y# ~4 t9 g% B
   inspect number" f! A/ i" R7 Y0 i5 T6 u+ R
       when 1 then
; x# P1 ^) K: F8 n. I$ d) O. q          print "not a prime number"
6 i/ Y/ B: l% a( r: E+ r       when 2,5,7,3 then + l0 q5 W3 D3 q5 m' h0 T' z% W
          print "prime number"# ^6 R% e) ?" y# U6 ^" S0 p
       when 9,4 then
) d0 }( {( ^7 E          print "square number"' I  s7 t' o0 Z* M: `0 F# M
       else' B+ X/ M$ Z/ V, o8 N0 m& J: n
          print "no special number";/ O5 s( ?4 q9 t8 e
          print "or number greater than 9";3 \* W0 v) S( ]
   end;
; B7 ]1 J* M  d4 O. v  O& |- Zend;
 楼主| 发表于 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-26 06:06 , Processed in 0.043240 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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