查看单个帖子
旧 2013-06-04, 12:57   #1
wang1234587
初级会员
 
注册日期: 2013-04-07
帖子: 5
声望力: 0
wang1234587 正向着好的方向发展
难过 求帮我看看这个While循环为什么是死循环

已知数据如下
qidian=4; zhongdian=3;
course =

1 2 0 4 1 0 0 0 1 0
been =

2 1
2 3
NaN NaN
1 4
5 1
NaN NaN
NaN NaN
NaN NaN
1 6
NaN NaN

我的程序代码如下
temppoint=zhongdian;
while 2
[m n]=find(been==temppoint);
tem=m;
for i2=tem;
if course(i2)~=0&course(i2)~=temppoint
xxx=been(i2,: );
newpoint=xxx(xxx~=temppoint);
st=[st newpoint];
break;
end
end
if newpoint==qidian
break;
end
temppoint=newpoint;
end

运行的时候是死循环,我检查了很多遍都没看出错误在哪里,求大神帮助!谢了
PS:我这个循环是用来从zhongdian出发,逐个搜索been,看他对应的course是否(既不等于0,也不等于temppoint),直到qidian
wang1234587 当前离线   回复时引用此帖