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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

小程序 || 语句_C ++开关语句| 查找输出程序| 套装1

發布時間:2025/3/11 编程问答 13 豆豆
生活随笔 收集整理的這篇文章主要介紹了 小程序 || 语句_C ++开关语句| 查找输出程序| 套装1 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

小程序 || 語句

Program 1:

程序1:

#include <iostream> using namespace std;int main() {switch (printf("Hello World")) {case 0x09:cout << " India";break;case 0x0A:cout << " Australia";break;case 0x0B:cout << " USA";break;case 0x0C:cout << " England";break;}return 0; }

Output:

輸出:

Hello World USA

Explanation:

說明:

The above code will print "Hello World USA" on the console screen.

上面的代碼將在控制臺屏幕上打印“ Hello World USA”

As we know that printf() function prints data on the console screen and returns the total number of characters printed on the screen.

我們知道, printf()函數在控制臺屏幕上打印數據,并返回屏幕上打印的字符總數。

printf("Hello World")

The above printf() function returns 11. And the hexadecimal equivalent of 11 is 0x0B, then case 0x0B will be executed.

上面的printf()函數返回11 。 并且十六進制的11等于0x0B ,那么將執行情況0x0B 。

And the final output is "Hello World USA".

最后的輸出是“ Hello World USA” 。

Program 2:

程式2:

#include <iostream> using namespace std;int main() {int A = 10, B = 5, C = 2;switch (A * ++B + C - 8) {default:cout << "Pakistan ";case 0x09:cout << "India ";break;case 0x0A:cout << "Australia ";break;case 0x0B:cout << "USA ";break;case 0x0C:cout << "England ";break;}return 0; }

Output:

輸出:

Pakistan India

Explanation:

說明:

The above code will print "Pakistan India " on the console screen. Here we pass an expression in the switch block. Based on the expression result, the case will be executed.?

上面的代碼將在控制臺屏幕上打印“ Pakistan India” 。 在這里,我們在switch塊中傳遞一個表達式。 根據表達式結果,將執行大小寫。

Evaluate the expression step by step:

逐步評估表達式:

int A=10,B=5,C=2;=A*++B+C-8 =10*6+2-8 =60+2-8 =54

The result of the expression is 54 and there is no such case is defined. Thus, the default case will be executed and then the case 0x09 will be executed (Because break statement is missing after in default case)

表達式的結果為54 ,沒有定義這種情況。 因此,將執行默認情況 ,然后執行情況0x09 (因為在默認情況下缺少break語句 )

Then the final output "Pakistan India" will be printed on the console screen.

然后,最終輸出“巴基斯坦印度”將打印在控制臺屏幕上。

Recommended posts

推薦的帖子

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

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

  • 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++ goto Statement | Find output programs | Set 1

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

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

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

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

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

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

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

  • 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

翻譯自: https://www.includehelp.com/cpp-tutorial/switch-statements-find-output-programs-set-1.aspx

小程序 || 語句

總結

以上是生活随笔為你收集整理的小程序 || 语句_C ++开关语句| 查找输出程序| 套装1的全部內容,希望文章能夠幫你解決所遇到的問題。

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