首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

怎样退出三重循环,该如何处理

2012-01-13 
怎样退出三重循环for i 1 to nfor each x in yfor j 1 to nif ...then跳到i循环next jnext xnext i[解

怎样退出三重循环
for i = 1 to n
  for each x in y
  for j = 1 to n
  if ...then
  跳到i循环
  next j
  next x
next i

[解决办法]
用 goto 简单

VB code
for i = 1 to nfor each x in yfor j = 1 to n   if ...then      goto ForOver   End Ifnext jnext xnext iForOver:
[解决办法]
探讨
用 goto 简单

VB code

for i = 1 to n
for each x in y
for j = 1 to n
if ...then
goto ForOver
End If
next j
next x
next i
ForOver:

[解决办法]
探讨
for i = 1 to n
for each x in y
for j = 1 to n
if ...then
跳到i循环
next j
next x
next i

热点排行