设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9506|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
3 k0 K: i" ~- {% E; u, A& q       Ci :integer; qi : integer5 n( Q# o" p( h$ z/ O( g
do # `: y# v3 t9 S! P$ t
       inspect Ci
  Y' s& s$ A0 _when Ci>0 and Ci <=150 then
: e5 H/ H: F% g* b       print qi=1;; \8 ^: R6 c$ F# M
when Ci>151 and Ci<=500 then8 m( H, l! z/ e8 J$ Y: G
       print qi=2;
3 B% C+ n4 @% e- q! l" Wwhen Ci>501 and Ci<=700 then5 Y9 @9 W+ d: m) [: {7 P6 K
       print qi=3;& Q6 J# P$ ~# X) h4 @) f7 i
when Ci>701 and Ci<=1000 then
- _/ _, T2 ~3 x1 D& I6 ?       print qi=4;
, r/ h$ ^0 ^0 Hwhen Ci>1001 and Ci<=2000 then
) D5 Z, o* I* a  I  j7 P" }       print qi=5;- ]! `' ^2 u4 r/ R
when Ci>2000 then% k( b0 w: k, b$ V' K
       print qi=6- Z/ ?% ^: O' N1 \& s1 }9 i! v( U
end;* p6 v9 l' w3 A3 |9 o
end;
' [2 @! |! \% a! C& @7 N, H
% |9 L0 O$ X) B0 Q/ K          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?& F6 H6 ]; Y5 O0 y
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:0 c6 c: M9 X  r( C) M, ]3 H
(number : integer)
  b: ^8 v% b5 r# M3 O6 Ois
8 w, B$ y9 K$ a4 ^% k7 u0 m; vdo
' n' a2 v; `0 O- X8 C9 u   inspect number/ {; v' C  S2 U! e
       when 1 then % V7 P$ o: x8 n, {; o6 I
          print "not a prime number"
3 }2 d. S7 e2 O& @. T* Z# K       when 2,5,7,3 then
9 Z( S+ W5 ~: g          print "prime number"9 a. P' U; f. m
       when 9,4 then
8 _0 v; t% v' k/ z/ I          print "square number"
+ F, U; X3 X6 H6 B% A       else
+ z4 V6 x* w4 a3 n  o          print "no special number";
. g$ N2 `0 @! k0 F1 F          print "or number greater than 9";
5 S0 _/ S  m  O; P8 ~; }3 f   end;
' ]1 U/ d& t; E" ]* s$ Gend;
 楼主| 发表于 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-23 10:38 , Processed in 3.453814 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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