设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1712|回复: 0

关于for循环的小心得

[复制链接]
发表于 2012-11-12 13:33:13 | 显示全部楼层 |阅读模式


模型描述:小车上有一个装有许多item的托盘,使用一个简单的协作任务序列:要求搬运员将这些item 移动到Queue1 中,
最后将 pallet 移动到Queue2
>>>>>>content()命令在一次触发中出现多次, <<<<<<<
关键代码如下:
int contn = 0;    //记录搬运次数
for( i =1 ; i<=content(pallet)  ; i++ )
{    let op load the item from pallet , and put it on queue1    //op   =  operator
     contn = 1 + contn ;
      }
if ( contn == content (pallet ) )
{     let op load the pallet from car , and put it on queue2      //car
}
这段代码中,content(pallet)的值在for()中和在if()中是相等的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2024-5-7 01:31 , Processed in 0.013006 second(s), 14 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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