设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9105|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is8 Q8 t: ?# G+ ^/ e
       Ci :integer; qi : integer# C  @7 q' p, B2 o3 f
do
& g. q+ `1 f3 t' T       inspect Ci$ k* e; {/ \% S9 H( }
when Ci>0 and Ci <=150 then
) T! ^% f3 E7 M       print qi=1;
! ^) l: k4 Z+ Q6 s2 s! Z2 c5 c! h8 uwhen Ci>151 and Ci<=500 then6 Q3 K4 j" R9 T+ ^
       print qi=2;$ c) R! y$ C% G2 x3 o
when Ci>501 and Ci<=700 then
/ Z0 @$ Y4 F$ I0 e3 f" |& j       print qi=3;
- x' G& z5 A" d# Fwhen Ci>701 and Ci<=1000 then
% t; M; i4 y+ G/ N       print qi=4;
& e8 d5 s8 X- @2 h, Hwhen Ci>1001 and Ci<=2000 then
! C2 }* E' K& s8 `* D       print qi=5;
3 k  j$ a6 `* }/ z6 d  I' S8 v$ ewhen Ci>2000 then6 o, K$ g8 q3 l! C; j
       print qi=67 l3 X7 C) v5 Y$ H; I
end;
) h2 N- S9 H, [( gend;& I. j- q# c8 U; b7 {0 \9 P' _

$ {5 Y5 n- i3 J" l& y          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
" c6 P7 |4 ?8 B; |          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
  F5 G) [- m+ n, S6 {. u! q% S(number : integer)
5 V% Y1 G0 ]; D8 ~  z  s0 bis
5 X8 t7 o( n: ydo5 }% u+ \. W* u# N# c5 r
   inspect number/ ~8 `- m) _5 W
       when 1 then
' y/ y3 L; M+ ]! a          print "not a prime number"
( \  `* g4 M- d# K, {       when 2,5,7,3 then
  P9 n9 Y. p1 ?9 g3 c          print "prime number"
/ H' f) ?2 q& P/ X3 {- M, Y& k# o  b       when 9,4 then , {# ]# P! B9 \. s9 P' I
          print "square number"+ ?# r- Q( }) \3 c  g
       else
1 ?* \# N$ Q# ?  G5 g! Z          print "no special number";) E2 \4 m. h9 b& d- l% u
          print "or number greater than 9";
3 w3 X9 X$ w' c   end;
' ]; v; E! ~, H9 G4 Fend;
 楼主| 发表于 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-7-30 23:09 , Processed in 0.011735 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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