假设您有一个双重嵌套的 for,例如当您试图查看一个未排序数组中的项目是否在另一个未排序数组中时。例如,假设您有 2 个列表candidates
,并且corruptPeople
您正在浏览candidates
并跳过 中列出的列表corruptPeople
。
for( int i = 0 ; i < lenCandidates ; i++ )
{
// veto candidates[i] if candidates[i] is in corruptPeople at all
for( int j = 0 ; j < lenCorruptPeople ; j++ )
if( candidates[i] == corruptPeople[j] )
break_this_loop_and_then_continue_outer_loop ;
// initiate the eligible candidates
initiate( candidates[i] ) ;
}