SUM = A + B
LOAD A
ADD B
STORE SUM
01001101011111010001010000010111
01010011011110110101110000001011
01000111100010101011101001101011
抽象來說,電腦內包含了:
整合開發環境 (IDE)
編譯器 (Compiler)
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!" << endl;
return 0;
}
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
#include <iostream>
// 加註解
int main() {
std::cout << "Hello World!" << std::endl; // 要記得加上分號
return 0;
}
//
,加上單行程式碼註解(給人看的,隨意寫)#
,開頭的是前置處理指令(給編譯器看的)#include <檔案名>
std::cout
和 std::endl
都是在 iostream
中#include <iostream>
using namespace std;
int main() {
cout << "Hello World!" << endl; // 分號很重要!!
return 0; // 分號很重要!!
}
int
,整數 integer,後面有詳細介紹main()
,程式進入點{}
,程式區塊範圍return 0;
,程式正常結束std::cout << "Hello World!" << std::endl;
std::cout
,輸出到螢幕 (console output)<<
,串接要輸出的東西std::endl
,輸出換行(end-of-line);
」,結束這行指令std::cout << "Hello World!" << std::endl << "我愛資芽!";
或是
std::cout << "Hello World!" << std::endl;
std::cout << "我愛資芽!";
;
」#include <iostream>
using namespace std;
int main( ) {
cout <<
"Hello World!"
<< endl;
return 0;
}
1. 執行下列程式碼,看看有什麼不同
#include <iostream>
using namespace std;
int main() {
cout << "1 + 1" << endl;
cout << 1 + 1 << endl;
return 0;
}