天天看點

朝文分享(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 新學苑