-15
for(;;){ /********* infinite iteration**************/
  for(k=1;k<=8;k++){
                  loop1:
                     for(n=0; n<48;n++){
                        for(i=0; i<8; i++){
                               for(j=0; j<natm; j++){
                                             ...................
                                                statements;
                               }
                        }

                    }   
                  E[iter] /*** Result of three loops such as n,i,j ***/ 

                  if (E[iter] < E[iter-1])  
                  {
                    iter++;
                    print the value of E[iter];
                    /***again calculate the E[iter] ****/
                    goto loop1;
                  }
                  else if(E[iter]>E[iter-1])
                 {
/**   stop the current for loop of k and move to k=2 **/
     /*** here is the problem for me i want to get rid of this loop and goto to the next iteration for loop (k =2)***/  

                 }  

            }
      }
4

4 回答 4

0

基于@calccrypto评论:

如果要进入for循环的下一次迭代:

else if(E[iter]>E[iter-1])
{
     continue;
}
于 2013-04-03T09:36:08.253 回答
0

替换您的评论 / *这是问题所在......

continue;

continue 语句将跳过当前迭代并继续下一个迭代,而不会像要中断的那样中断整个循环;陈述。

于 2013-04-03T09:36:35.060 回答
0

您可以使用continue;上述答案显示的命令。或者尝试使用与goto loop1;命令相同的逻辑,将其置于for循环之上k

于 2013-04-04T02:19:24.383 回答
0

5 级for循环——这是一项了不起的成就!还有一个标签!我不会去猜测他们做了什么。

你需要:

else if (E[iter] > E[iter-1])
{
    /** stop the current for loop of k and move to k=2       */
    /** here is the problem for me I want to get rid of this */
    /** loop and goto to the next iteration for loop (k =2)  */
    k = 2;
    goto loop1;  
}

loop1标签就在循环for (k = 1; k <= 8; k++)内;k使用set to的值跳转到它将使用 进行2迭代k == 2

于 2022-03-04T05:42:22.660 回答