天天看点

朝文分享(33):初识C++(六)——登峰造极

作者:LearningYard学苑
朝文分享(33):初识C++(六)——登峰造极

分享兴趣,传播快乐,增长见闻,留下美好!

亲爱的您,这里是LearningYard新学苑。

今天小编为大家带来“初识C++(六)——登峰造极”,欢迎您的访问。

Share interest, spread happiness, increase knowledge, and leave beautiful.

Dear, this is the LearingYard Academy!

Today, first introduction to C++ (VI) - The pinnacle,welcome to visit!

朝文分享(33):初识C++(六)——登峰造极

一、循环嵌套

1. Loop nesting

循环嵌套,即循环中包含另一层或多层循环,通过两个或多个循环语句实现多重循环,解决问题。

Loop nesting, that is, the loop contains another layer or multiple layers of loops, through two or more loop statements to achieve multiple loops, to solve the problem.

朝文分享(33):初识C++(六)——登峰造极

二、循环嵌套案例——九九乘法表

2. Circular nesting cases - 99 times table

通过两层循环,依次实现因数相乘,输出九九乘法表。

Through two layers of loops, multiplication of factors is realized in turn, and multiplication table 99 is output.

朝文分享(33):初识C++(六)——登峰造极

三、跳转语句(一)——break语句

3. Jump statement (1) -- break statement

break语句用于跳出循环或者switch语句,多层循环时只能跳出该层循环,外层循环继续执行。

The break statement is used to exit the loop or the switch statement. In a multi-layer loop, only the loop of this layer can be exited, and the outer loop continues to execute.

朝文分享(33):初识C++(六)——登峰造极

四、跳转语句(二)——continue语句

4. Jump statement (2) -- continue statement

continue的作用是立即执行本层循环的下一次循环,continue与break一样,多层循环时,只作用于该层循。

The function of continue is to execute the next loop of this layer immediately. continue, like break, applies only to the loop of this layer.

朝文分享(33):初识C++(六)——登峰造极

五、跳转语句(三)——goto语句

5. Jump statement (3) - goto statement

goto语句是无条件无限制跳转语句,可跳出多层循环,,无逻辑,代码可读性差,故一般不用。

goto statement is an unconditional unlimited jump statement, can jump out of multi-layer loops, no logic, code readability is poor, so it is generally not used.

朝文分享(33):初识C++(六)——登峰造极

今天的分享就到这里了,

如果您对文章有独特的想法,

欢迎给我们留言。

让我们相约明天,

祝您今天过得开心快乐!

That's all for today's sharing.

If you have a unique idea about the article,

please leave us a message,

and let us meet tomorrow.

I wish you a nice day!

参考资料

《Python语言程序设计基础》

翻译:网易有道翻译

本文由LearningYard学苑整理并发出,如有侵权请后台留言沟通.

文案|Dongyang

排版|Dongyang

审核|hong

Learning Yard 新学苑