设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9353|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is* Q7 o5 n/ R. n# w; L( M
       Ci :integer; qi : integer! w; Y$ Y0 \4 w
do + N1 U6 z9 ^, V( U2 I- t
       inspect Ci4 k' x7 e: X- Z
when Ci>0 and Ci <=150 then
' ?1 [+ l( g% e# u/ v0 G2 L+ m6 |       print qi=1;, l& U. O) s, @9 p( Q+ ^( u  u
when Ci>151 and Ci<=500 then+ N. d4 Q* K. ]! c
       print qi=2;: i. i5 U' R1 f
when Ci>501 and Ci<=700 then
1 N! E% _+ S, t0 {  k; h; D2 j, Y       print qi=3;4 d/ @+ F, Y1 B9 D
when Ci>701 and Ci<=1000 then
( j# G% b. b. Y+ Y2 f8 g" m       print qi=4;$ x6 V& F) b$ Z% ^- ~$ B
when Ci>1001 and Ci<=2000 then
2 \% k$ q' g  i( F       print qi=5;
3 m/ V5 y' y$ Q8 t) wwhen Ci>2000 then
+ F) c6 [2 Z% @       print qi=6* K# H) O$ D1 e, a- U$ O% O/ f0 ^
end;
2 m* I& M) g+ I" Y0 N: Vend;0 v7 h7 e7 {$ o" ^+ ~: `0 `
+ r$ i; R8 c3 u) p" c- b" l
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
; ~9 c/ F! R3 L; M' M          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:" x3 M1 Q" I# d9 ^, l+ H) m6 v3 H
(number : integer)
# I# `0 E$ x# @! eis( }+ K$ g/ P9 p* V- G5 F
do
7 z* ~, V" M0 ~# [   inspect number+ Y  Q0 {# G7 Q8 m3 z: L
       when 1 then 1 R$ i8 a& U: X" R) A6 J8 M
          print "not a prime number"$ I- q4 u4 J( X% h0 L
       when 2,5,7,3 then
4 A+ B3 s0 e  `& c' W0 ?          print "prime number"
; p. M, K' Q2 m' O       when 9,4 then 1 Z+ v8 l1 j7 @+ [. C) T6 [3 F" k
          print "square number"0 M5 N3 a8 F. Z- q. J
       else7 y2 Q$ F+ \7 c( N  x8 ?
          print "no special number";
6 ^( P0 [; A9 q" b  U          print "or number greater than 9";
# {! }( ^  I  I6 p   end;
+ C3 y) @5 L5 L! ?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-9-6 00:19 , Processed in 0.014218 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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