先從Hello World!說起
先對K&R致敬,在此先使下C++,寫個Hello World。
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}code 1-1
程式執行順序
#include <iostream> //1.
using namespace std; //2.
int main()
{
//3.
return 0; //4.
}
//2.引用的外部檔案
全域宣告
主程式內部程式碼
主程式回傳值,同時也代表主程式結束
在此主要要介紹的語法都會在主程式的大括號內執行。
(主程式的)程式行為描述
範例程式
寫一個幫我們算數學的程式碼,在此就以我當年在大學一年級的期中考題目為例: 顯示99乘法表。
這算是....數學課本裡的東西。
另外,英文課本裡的對話內容也可以拿來練習。
code 1-2 完整程式碼
Last updated
Was this helpful?