循环半控制 [英] loop and a half controlled
本文介绍了循环半控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们什么时候使用循环半?另外,是否应该有人简要说明如何编写其代码?
When do we use loop and a half? Also, should someone briefly elaborate how to write its code?
推荐答案
您使用循环半来避免从循环外部到内部重复代码.示例:
You use loop-and-a-half to avoid repeating code from outside the loop to the inside. Example:
read a;
while a != b do
stuff;
read a;
end
变成
while true do
read a
if a == b then break
stuff;
end
现在我只能在一个地方阅读.
Now I only have the read in one place.
这篇关于循环半控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文