设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8796|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is+ N/ ?0 w# ]0 a& \/ b% l
       Ci :integer; qi : integer
8 U. B6 m9 j. ]0 ]3 y* U! X/ ?+ x; `do * s6 E  K& \& V1 [8 R
       inspect Ci
' ]: d. \+ s) g* X! L* [when Ci>0 and Ci <=150 then
0 z3 e# |$ g; e7 M# x% I- e       print qi=1;6 j- ?/ @: Z  H/ l
when Ci>151 and Ci<=500 then8 ]# z3 P# _" a' E+ p' Y
       print qi=2;8 J2 g! J- k' ]. H; `' O( g
when Ci>501 and Ci<=700 then/ ?. }: G7 ^; I9 `. F
       print qi=3;  x4 j' X9 \: \" n! z* _7 E
when Ci>701 and Ci<=1000 then8 F8 B) Q0 G' A% [" L8 G. Y; \
       print qi=4;  E& V; z/ @" H8 D; `
when Ci>1001 and Ci<=2000 then
- Y+ G$ H) O7 {       print qi=5;$ p( N# @2 Q% ^- Q$ k9 o+ O& G
when Ci>2000 then' [7 n& D4 h: S' u! t8 m
       print qi=6
( M# B6 s$ l. w, J- z7 p" wend;
, k% x7 I$ n1 J! O! g4 f7 @7 cend;3 E4 V; v; z; T
7 W+ }* o- b8 \1 ~* K
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?( W* J+ F8 d( F5 R
          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:
! b8 n# R9 R5 a$ m% T+ B4 p2 T5 `- G(number : integer)9 C% B8 N( n4 ~0 H
is
! g# C& w3 {4 A( p( Y6 Q1 h0 K/ Vdo  U0 Q0 d8 a& n8 q5 r; W4 D
   inspect number
, S5 F% L' q- ~8 s       when 1 then
7 W$ T: F' t, e  v$ h0 H$ c9 O          print "not a prime number"' \' l  Z) R! e; c* e4 l
       when 2,5,7,3 then
* [7 ^) ]1 u2 M* T# z4 C3 o          print "prime number"
6 [1 [; {5 V+ U+ L2 H; J0 e       when 9,4 then
+ t" A4 `6 q4 _0 [          print "square number"$ N  C6 G& l# F( Y4 s3 {: ]
       else- p" D# K4 k- R! I! S" q
          print "no special number";- ?; u: V( E0 e1 H% A
          print "or number greater than 9";
4 H- t. Q* L; [   end;+ g! A. E6 }( ^" x0 W
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-6-30 11:54 , Processed in 0.011675 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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