设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8575|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
: ~3 M- L- y9 f- U: A       Ci :integer; qi : integer9 M; _5 x3 {: A2 q
do
$ Z, J. v+ m( a       inspect Ci$ Y8 `- }8 j5 ~
when Ci>0 and Ci <=150 then 7 q5 I$ U5 R2 ~0 ~( v3 x
       print qi=1;
9 }1 U, y$ c* d% C; K- C# T: Xwhen Ci>151 and Ci<=500 then
' w; ]- H# `, y1 a5 G9 W3 }       print qi=2;
7 t4 M. ~# }( T! Qwhen Ci>501 and Ci<=700 then
/ P0 e9 w6 A3 }       print qi=3;& h3 C/ D3 w# [# g& Y" K, `
when Ci>701 and Ci<=1000 then) U7 _, O7 u, ~3 Z1 D- |, @
       print qi=4;
0 Z$ }$ X8 B: C1 ywhen Ci>1001 and Ci<=2000 then
, M& N; [* ]# y- m  [3 `6 G# q       print qi=5;
  D0 n2 w8 K! qwhen Ci>2000 then5 {; Z+ j$ E9 P7 l  P  M4 z, P
       print qi=6- t& k- ^) K) k5 I( C* s
end;
( J. V; M6 Y, T4 E6 U! Q6 H  kend;' V5 T' P; p% t5 M8 I

$ X4 F+ V1 Y  {" Y( G          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?% x- V3 `& ?% H
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:* E4 D- h. I% p# S) A% U
(number : integer)6 c" C: n. z5 h+ h; [
is
% q. S, N. Q( D' I, Qdo. L6 d; R$ J4 j0 o5 {: g
   inspect number
# E8 L9 m; A6 @7 N/ d" P       when 1 then
  N8 K9 @  E! V2 E  Y% v          print "not a prime number"
* J# k: L" R+ i0 Y5 i  F2 g       when 2,5,7,3 then ! P# t/ n. V5 @  ]1 v" [, I
          print "prime number"
1 [' d9 ^; y# S1 G( F! Y2 E/ J       when 9,4 then & t( T- N% j0 M8 d5 H
          print "square number"
6 J; t* k1 S  T7 R5 q) `       else
8 P0 R& K: V4 B3 @0 r          print "no special number";3 |. v- J$ Z* e5 e
          print "or number greater than 9";
- s0 J- |$ {! F9 Z8 I   end;
5 i5 K) g& J, Bend;
 楼主| 发表于 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-5-12 18:16 , Processed in 0.013565 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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