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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

斯威夫特山地车_斯威夫特| 两个数字相加的程序

發布時間:2023/12/1 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 斯威夫特山地车_斯威夫特| 两个数字相加的程序 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

斯威夫特山地車

In this program, we will have an idea - how two numbers can be added and displayed as the output on the screen?

在此程序中,我們將有一個想法- 如何將兩個數字相加并顯示為屏幕上的輸出 ?

Open XCode terminal and type the following program

打開XCode終端并鍵入以下程序

import Foundation var num1 = 4; var num2 = 6; var ans = Int(); ans = num1+num2; print("num1 + num2 = ",ans);

Output

輸出量

num1 + num2 = 10 Program ended with exit code: 0

Explanation:

說明:

  • import Foundation is a library which is used to access all the functions present that header file.

    import Foundation是一個庫,用于訪問該頭文件中提供的所有功能。

  • var is a data type with num1 as a variable whose value is initialized as 4. Similarly, num2 is a variable with same data type whose value is initialized as 6.

    var是一種數據類型,以num1作為變量,其值初始化為4 。 同樣, num2是具有相同數據類型的變量,其值初始化為6 。

  • Whereas, var ans includes same data type with ans as a variable where the result is stored.

    而var ans包含與ans相同的數據類型,而ans作為存儲結果的變量。

  • print function prints the string with the answer on the output screen.

    打印功能在輸出屏幕上打印帶有答案的字符串。

  • Whereas, "program ended with exit code: 0" at the end shows that there are no further programs to be run.

    而結尾處的“程序以退出代碼0結尾”表示沒有其他程序要運行。

  • Semicolon ";" is must after every end of the command as similar in C/C++ etc.

    分號“;” 在命令的每個結尾之后必須是,類似于C / C ++等。

翻譯自: https://www.includehelp.com/swift/addition-of-two-numbers.aspx

斯威夫特山地車

總結

以上是生活随笔為你收集整理的斯威夫特山地车_斯威夫特| 两个数字相加的程序的全部內容,希望文章能夠幫你解決所遇到的問題。

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