设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7816|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is6 M& b8 a5 L; V; g% p4 k9 {/ o
       Ci :integer; qi : integer
# z# G& p. _" X3 h2 |do ' n* V" B/ ~: [
       inspect Ci
4 F2 C( y' e# {) M' Zwhen Ci>0 and Ci <=150 then & A* z- q5 q) `& d
       print qi=1;
9 Y# |$ Z0 {0 ^6 y0 @2 kwhen Ci>151 and Ci<=500 then
9 o5 u6 i. Z0 J       print qi=2;8 N6 z* A. g, Q/ q  Z/ d
when Ci>501 and Ci<=700 then8 W& U* j. I& y" ^0 g
       print qi=3;( o( U. Q, l+ P# N. p
when Ci>701 and Ci<=1000 then
! w* u! P5 @! Z       print qi=4;& h: I& `: y% K  Y) Z
when Ci>1001 and Ci<=2000 then4 ?9 v0 w5 }8 S, e( {6 |; v4 N
       print qi=5;
$ r2 k6 U" E& Y  |  P0 n5 Qwhen Ci>2000 then* x" J" U# w9 t' n( Q- A$ i+ F- y
       print qi=69 x) c- t, f6 U- O7 l. C; P% h- C3 ^
end;% W4 z4 v" |, N( l
end;
) @9 N4 _" ?6 Z" c! _0 {$ _! a
  }% \$ e- x. t4 g' Z* d          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
. T3 J" L, E/ x3 T          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:( H/ \2 S! y# C2 E
(number : integer)2 P; n4 n: I, d  o, |! I
is
( S) R* d% J# O) t. E. r/ y6 Vdo- Y* T! `9 f/ v% L" B
   inspect number
6 m8 V: Q8 _& B) P       when 1 then
. q) }/ _$ s* q& e9 |$ z          print "not a prime number"
% h3 i) e# J- Z  ]       when 2,5,7,3 then
/ p" k. b% P1 O7 a! z7 x: a. m# @          print "prime number"
% T* O& r4 V+ F, u       when 9,4 then 0 l9 ~) h8 x8 N) H! Z. x
          print "square number"
3 p9 O! z% X, T, o       else: B4 C+ x8 o& K* H! R! b( E" y
          print "no special number";5 ~& z/ i% N$ A8 d( W' J
          print "or number greater than 9";
3 X/ _! L6 D- D1 s  J1 o   end;
$ m" g: w4 M% A' F% 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-1-29 13:53 , Processed in 0.014350 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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