设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4595|回复: 5

[求助] Inspect 编程问题

  [复制链接]
发表于 2009-5-12 20:16:59 | 显示全部楼层 |阅读模式
5仿真币
is
( E9 y8 L5 z' _2 y. A$ n       Ci :integer; qi : integer
. n* K  ^7 v- Ldo
# y# E% J+ j' g- g4 }. l& b# x       inspect Ci
4 A/ S# _+ @2 q6 M1 r# Ywhen Ci>0 and Ci <=150 then
6 l* x; \) O, O1 o       print qi=1;
2 q7 ~6 K) ~+ `$ y# awhen Ci>151 and Ci<=500 then
$ ?6 o- s: ]# }: a8 o: ^+ N# @       print qi=2;- }7 P6 C% h  B+ m9 x. i) a+ l
when Ci>501 and Ci<=700 then
$ X9 i# Q: t5 ]3 ^% [$ _       print qi=3;$ i! l+ K& ]5 F! }! Y
when Ci>701 and Ci<=1000 then
$ y0 D5 T7 _7 F  _) H) X       print qi=4;
  g2 r8 c2 J% M  S! B. c) p( c, gwhen Ci>1001 and Ci<=2000 then
4 f: C8 U' k9 U% G& |- j) l       print qi=5;! j+ @% B* |7 P
when Ci>2000 then
8 u0 J* e- T7 p       print qi=6
5 b5 q% Q& {) s2 T0 y4 \2 Rend;8 i: ^; J/ Z; G
end;
- m) N! V. T, N( `' @+ S7 f; o4 k* r' n
          运行提示line 5附近的Ci 句法错误,想请教一下各位高手!如何解决?
$ q) t3 P6 ^6 S3 g) u5 C          谢谢!

发表于 2009-5-12 23:36:09 | 显示全部楼层
inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下:% ]$ W3 N' R7 d8 a2 [
(number : integer), Y3 t" K0 D) o% U" N; D4 ^
is
) k, ^, f: N+ [do
3 l  q" V  S( ], ]2 D# b   inspect number
  e" c* M3 i9 T2 _! G# o2 R6 P       when 1 then 9 Q( S$ N: H; }( b- @! i
          print "not a prime number"1 |( {$ }2 n( W$ [! t! F: j
       when 2,5,7,3 then : W) p' R* t2 x7 {+ J
          print "prime number"
* _* I4 V7 T' {2 l  E       when 9,4 then
# m4 w6 _7 m' Z  V0 [! B( S) W$ l          print "square number"
2 y. k, x& T6 W0 ~  j9 w       else6 T( w- v; ~' V6 O
          print "no special number";% i& t" X7 M7 I' g
          print "or number greater than 9";$ P1 n. J  U, {* c4 s" J: |
   end;
- }& ?' Q# k* Wend;
 楼主| 发表于 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, 2024-6-2 04:18 , Processed in 0.012203 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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