gpt4 book ai didi

c++ - C 多循环 for() 基础知识

转载 作者:太空宇宙 更新时间:2023-11-04 01:23:03 25 4
gpt4 key购买 nike

如何在没有 goto 和额外过程调用的情况下编写示例代码?

for(i=0;i<imax;i++)
{ for(j=0;j<jmax(i);j++)
{ for(c=0;c<cmax(j);c++)
{ if(!check1(c))
{ if(check2()) goto ni;
else goto nj;
}
}
// **EDIT** procedure call is here
nj:;
}
ni:;
}

最佳答案

检查这段代码:

    bool flag = false;
for(i=0;i<imax;i++)
{ for(j=0;j<jmax(i);j++)
{ for(c=0;c<cmax(j);c++)
{ if(!check1(c))
{ if(check2()) {flag=true;break;}// goes to ni
else break; //goes to nj
}
}
if(flag){flag=false; break;}
nj:;
}
// procedure
ni:;
}

关于c++ - C 多循环 for() 基础知识,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36899735/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com