设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6512|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
1 D7 |1 w3 O7 }/ N2 G% Y       Ci :integer; qi : integer
9 B) s6 B1 y+ Q. F8 z1 Z5 sdo . L0 a' R1 ^- ?  {- I; ~7 b4 v
       inspect Ci6 P% R. y; }8 n$ G
when Ci>0 and Ci <=150 then
9 I9 v) B$ F9 s4 n- _8 f2 b       print qi=1;' x3 n: F# {5 }) f/ h% m
when Ci>151 and Ci<=500 then8 A6 X2 w* S* \( z: w$ s5 ?
       print qi=2;& D' s4 ]8 h% U7 N5 o
when Ci>501 and Ci<=700 then
1 e" B; v! Y" @0 d( [3 {       print qi=3;0 z" q4 B. _4 q* ~( E& z
when Ci>701 and Ci<=1000 then
; M3 E0 j1 }8 ?4 Q       print qi=4;* r9 K# X6 D3 q' w! X! g
when Ci>1001 and Ci<=2000 then+ e8 i. n( A: a
       print qi=5;
3 h# @4 N7 K" ^6 \# g6 ?# [. wwhen Ci>2000 then+ Y9 ]* A7 Y: [
       print qi=68 W7 e! v0 h$ _! N6 S
end;3 Q% H) u" o8 F3 y3 r8 C" a  F6 A
end;
0 z$ ?0 I: r; {! s8 y" \* Z9 C
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?" s: g( K& p1 q3 I- L! q# M
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
# J- P" u1 W) n(number : integer)) ?$ ^; ^! p2 x0 Y
is
. L4 K  f* T, W# _do- ?8 v* _5 p/ L$ E+ Z8 C3 R
   inspect number
6 b; W7 w* }& n( e- ]! v7 r5 {       when 1 then / b1 A( V- P( q$ h
          print "not a prime number"
4 P5 V( o$ n9 L$ i2 a2 `$ c       when 2,5,7,3 then
( Q; O6 }$ {# }3 [# A* I& A          print "prime number"# F1 ~  k+ O) L& P
       when 9,4 then 7 {/ W/ a1 [; g
          print "square number"& }+ i" l  w0 c/ h( }' y
       else
% C7 u5 d1 C! e. d          print "no special number";- p% K3 `" A; \$ N) l
          print "or number greater than 9";
3 s7 r& @7 G; D! I1 S2 e   end;
  g* x* s  p2 y$ x2 Yend;
 楼主| 发表于 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-7-6 16:36 , Processed in 0.013434 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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