What is the difference between perfectly nested loop and imperfectly nested loop?

别说谁变了你拦得住时间么 提交于 2019-12-13 05:24:34

问题


I wanted to know what is the difference between perfectly nested loop and imperfectly nested loop?


回答1:


See this: openmp g++ error: collapsed loops not perfectly nested.

A perfectly nested loop is one wherein all content is in the innermost loop. For instance,

foreach(var a in vals1)
{
    foreach (var b in vals2)
    {
        Console.WriteLine(a + b);
    }
}

As compared to an imperfectly nested one,

foreach(var a in vals1)
{
    Console.WriteLine("values for " + a);

    foreach (var b in vals2)
    {
        Console.WriteLine(a + b);
    }
}

Of course, I'm a C# guy and this is C# where nobody I know of uses such terms and it doesn't matter at all, but you see the point. Just consider this pseudo-code that compiles under the right circumstances.



来源:https://stackoverflow.com/questions/24749801/what-is-the-difference-between-perfectly-nested-loop-and-imperfectly-nested-loop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!