close

主程式都有一個以上的函式(function)’main’這個函式就是一個開頭,以這個為基準,下面來介紹結構。

 

image

主體裡面有一個return 0;,主要的用意是告訴作業系統你執行完了,沒有錯誤所以回傳0,回傳1就代表執行之間有誤。

原始碼(source code) :程式碼。

大括號(open curly brace)ex: {

內建型別(built-in type) ex: intfloatchar

分號(semicolon) ex: ;

後綴(suffix) ex: .c .cpp .o

句號(period) ex: .


IDE(integrated development environment,整合式開發環境)

image

命令列介面(command-line interface):文字使用介面

image

認識輸入/輸出(IO)

iostream式最為常用的標準程式庫(standard library),包含4個物件

  1. cin 標準輸入(standard input)
  2. cout 標準輸入(standard output)
  3. cerrclog 標準錯誤(standard error)

 

使用輸入輸出流:

image

結果:

image

 

角括號(angle brackets) ex: <

標頭(header)ex: #include

雙引號(double quotation marks)ex: “

操作符(manipulator): endl 換行、會把緩衝區(buffer)的資料清除,確保輸出的東西不會存在記憶體中等待輸出。

命名空間(namespace) ex: std

範疇運算子(scope operator ::) ex: std::cout 為了知道是哪個函式庫,所以加上::

 

註解(comments):單行(single line)、成對(paired)

image

while:

image

結果:

image

運算子(less-than-or-equal operator,<=) ex: a>= b

複合指定運算子(compound assignment operator +=)ex: a += b;

前綴遞增運算子(prefix increment operator ++) ex: ++a;

後綴遞增運算子(suffix increment operator ++) ex: a++;

前綴遞減運算子(prefix decrement operator --) ex: --a;

後綴遞減運算子(suffix decrement operator --) ex: a--;

for:

image

image

結果:

image

while(無限輸入)

image

結果:

image

 

if(計算連續輸入值的次數):

image

 

結果:

image

最後輸入一個非整數結束while迴圈。

 

縮排(indentation)

可讀性(readability)

類別型別(class type)

檔案重導(file redirection)

成員函式(member function) == 方法(methon)

點號運算子(dot operator .)

呼叫運算子(call operator ())

括號(parentheses)

 

 

參考書籍: https://www.tenlong.com.tw/products/9789865021726?list_name=srh

arrow
arrow
    創作者介紹
    創作者 讀書小天地 的頭像
    讀書小天地

    書籍分享天地

    讀書小天地 發表在 痞客邦 留言(0) 人氣()