日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

多线程循环输出abcc++_C ++循环| 查找输出程序| 套装2

發布時間:2025/3/11 c/c++ 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 多线程循环输出abcc++_C ++循环| 查找输出程序| 套装2 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

多線程循環輸出abcc++

Program 1:

程序1:

#include<iostream> using namespace std;int main() { for(;;){cout<<"Hello ";}return 0; }

Output:

輸出:

Hello Hello .... Infinite loop

Explanation:

說明:

In the above code, the loop will execute infinitely. In C++, if we did not mention any condition in the loop then I will consider it as a true. Then the condition will never false, so the loop will never terminate. Then the "Hello" will print infinite times on the console screen.

在上面的代碼中,循環將無限執行。 在C ++中,如果我們在循環中沒有提及任何條件,那么我將其視為真實情況。 然后條件將永遠不會為假,因此循環將永遠不會終止。 然后,“ Hello”將在控制臺屏幕上無限次打印。

Program 2:

程式2:

#include <iostream> using namespace std;int main() {for (; EOF;) {cout << "Hello ";}return 0; }

Output:

輸出:

Hello Hello .... Infinite loop

Explanation:

說明:

In the above code, the loop will execute infinitely. In the above code w mentioned EOF in place of loop condition, In C++, EOF is a predefined MACRO, the value of EOF is -1. And as we know that, In C++ any non-zero value is considered as a true for conditions. so the loop will never terminate. Then the "Hello" will print infinite times on the console screen.

在上面的代碼中,循環將無限執行。 在上面的代碼w中,提到了EOF代替循環條件,在C ++中, EOF是預定義的MACRO, EOF的值為-1。 眾所周知,在C ++中,對于條件,任何非零值都被認為是正確的。 因此循環永遠不會終止。 然后, “ Hello”將在控制臺屏幕上無限次打印。

Program 3:

程式3:

#include <iostream> using namespace std;int main() {int i = 0;int a = 10, b = 10;while (a > b ? 0 : 1) {i++;cout << "Hello ";if (i > 2)break;}return 0; }

Output:

輸出:

Hello Hello Hello

Explanation:

說明:

Here, we declared three local variables i, a, and b with initial values 0, 10, 10 respectively. Here we use a while loop.

在這里,我們聲明了三個局部變量iab ,其初始值分別為0、10、10。 在這里,我們使用一個while循環。

Let's understand the condition of a while loop.

讓我們了解while循環的條件。

while(a>b?0:1)

In the while loop, we used a ternary operator, here condition (10>10)? is false then it returns 1, so the condition for while loop will be true always.

在while循環中,我們使用了三元運算符,此處條件(10> 10)為false,然后返回1,因此while循環的條件始終為true。

In the body of the while loop we used a counter variable i and cout<<"Hello " to print "Hello " on the console.

在while循環的主體中,我們使用了計數器變量i和cout <<“ Hello”在控制臺上打印“ Hello”

Here "Hello " will be printed 3 times, because the loop will terminate when the value of the variable i becomes 3 that is greater than 2.

此處“ Hello”將被打印3次,因為當變量i的值變為大于2的3時,循環將終止。

Recommended posts

推薦的帖子

  • C++ Looping | Find output programs | Set 1

    C ++循環| 查找輸出程序| 套裝1

  • C++ Looping | Find output programs | Set 3

    C ++循環| 查找輸出程序| 套裝3

  • C++ Looping | Find output programs | Set 4

    C ++循環| 查找輸出程序| 套裝4

  • C++ Looping | Find output programs | Set 5

    C ++循環| 查找輸出程序| 套裝5

  • C++ Operators | Find output programs | Set 1

    C ++運算符| 查找輸出程序| 套裝1

  • C++ Operators | Find output programs | Set 2

    C ++運算符| 查找輸出程序| 套裝2

  • C++ const Keyword | Find output programs | Set 1

    C ++ const關鍵字| 查找輸出程序| 套裝1

  • C++ const Keyword | Find output programs | Set 2

    C ++ const關鍵字| 查找輸出程序| 套裝2

  • C++ Reference Variable| Find output programs | Set 1

    C ++參考變量| 查找輸出程序| 套裝1

  • C++ Reference Variable| Find output programs | Set 2

    C ++參考變量| 查找輸出程序| 套裝2

  • C++ Conditional Statements | Find output programs | Set 1

    C ++條件語句| 查找輸出程序| 套裝1

  • C++ Conditional Statements | Find output programs | Set 2

    C ++條件語句| 查找輸出程序| 套裝2

  • C++ Switch Statement | Find output programs | Set 1

    C ++轉換語句| 查找輸出程序| 套裝1

  • C++ Switch Statement | Find output programs | Set 2

    C ++轉換語句| 查找輸出程序| 套裝2

  • C++ goto Statement | Find output programs | Set 1

    C ++ goto語句| 查找輸出程序| 套裝1

  • C++ goto Statement | Find output programs | Set 2

    C ++ goto語句| 查找輸出程序| 套裝2

翻譯自: https://www.includehelp.com/cpp-tutorial/looping-find-output-programs-set-2.aspx

多線程循環輸出abcc++

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的多线程循环输出abcc++_C ++循环| 查找输出程序| 套装2的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。