C++ Syntax Camp Note Guide
Quick Index
- Who Is This For?
- Use These 5 Sections Every Class
- The 6 Markdown Features You Need Most
- Common C++ Syntax Camp Note Topics
- Common Mistake Checklist
- Do Not Rush Into Hard Notes
- Copy This Class Note Template
- When You Want More Complete Notes
- Summary
Who Is This For?
This guide is for students joining the C++ syntax camp for the first time. You may have just started learning cout, cin, variables, if, and for loops. You do not need long competitive-programming notes yet.
During the camp, a good note only needs three things:
- Record what you learned today.
- Keep a short C++ example that you can understand.
- Write down what confused you or what you often forget.
A note is not an exam paper. It does not need to be perfect. Start short and clear, then make it better over time.
Use These 5 Sections Every Class
You can use the same format every class. This makes note writing much easier.
## Class 1: Input, Output, and Variables
### What I Learned Today
- `cout` can print words and numbers.
- `cin` can read input.
- `int` stores integers.
### Teacher's Example
```cpp
#include <iostream>
using namespace std;
int main() {
int age;
cin >> age;
cout << age << '\n';
}
```
### My Own Small Change
I changed `age` to `score` and practiced reading a score.
### What Confused Me Today
- I forgot to add `;` at the end of a line.
- I often write the arrows in `cin >> age;` backwards.
### Check Before Coding Next Time
- [ ] Did I write `#include <iostream>`?
- [ ] Did I write `using namespace std;`?
- [ ] Did I write `int main()`?
- [ ] Do the braces `{}` match?
- [ ] Did I add `;` where needed?
If you do not know what to write, start by filling in this format.
The 6 Markdown Features You Need Most
Headings
Headings split your note into sections. For syntax-camp notes, ## and ### are usually enough.
## Class 2: if Statements
### What I Learned Today
### Teacher's Example
### What Confused Me Today
Lists
Lists are good for key points:
- `int`: integer
- `double`: decimal number
- `char`: one character
- `bool`: true or false
Rendered:
int: integerdouble: decimal numberchar: one characterbool: true or false
Checklists
Use checklists before submitting code:
- [ ] Did I spell the variable names correctly?
- [ ] Is the `if` condition inside parentheses?
- [ ] Does the loop run the correct number of times?
- [ ] Does the output match the problem statement?
Bold Text
Use bold for important reminders:
**`=` means assignment. `==` means checking equality.**
Rendered:
= means assignment. == means checking equality.
C++ Code Blocks
For C++ examples, use three backticks and write cpp after the first three:
```cpp
int x;
cin >> x;
cout << x + 1 << '\n';
```
Rendered:
int x;
cin >> x;
cout << x + 1 << '\n';
This makes code easier to read and helps you notice missing symbols.
Tables
Tables are useful for organizing "syntax, meaning, example":
| Syntax | Meaning | Example |
|---|---|---|
| `int` | integer | `int n;` |
| `double` | decimal number | `double x;` |
| `char` | one character | `char c;` |
Rendered:
| Syntax | Meaning | Example |
|---|---|---|
int |
integer | int n; |
double |
decimal number | double x; |
char |
one character | char c; |
You can add colons to align a column:
| Syntax | Meaning | Example |
|:---:|---|---|
| `int` | integer | `int n;` |
A colon on the left means left-aligned, colons on both sides mean centered, and a colon on the right means right-aligned.
Common C++ Syntax Camp Note Topics
Variables
## Variables
A variable is like a named box that stores data.
| Type | What it stores | Example |
|---|---|---|
| `int` | integer | `int age = 12;` |
| `double` | decimal number | `double height = 150.5;` |
| `char` | one character | `char grade = 'A';` |
| `bool` | true or false | `bool ok = true;` |
Easy to forget: a character uses single quotes, like `'A'`.
if Statements
## if Statements
`if` checks a condition first. If the condition is true, it runs the code inside the braces.
```cpp
int score;
cin >> score;
if (score >= 60) {
cout << "pass\n";
} else {
cout << "fail\n";
}
```
Common mistakes:
- Use `==` to compare equality, not `=`.
- Put the condition inside parentheses `()`.
for Loops
## for Loops
A `for` loop repeats the same action many times.
```cpp
for (int i = 1; i <= 5; i++) {
cout << i << '\n';
}
```
This prints 1 through 5.
Mistakes I often make:
- Forgetting `i++`, so the loop may never stop.
- Confusing `i < n` and `i <= n`.
Arrays
## Arrays
An array stores many values of the same type.
```cpp
int a[5];
for (int i = 0; i < 5; i++) {
cin >> a[i];
}
```
Note: if an array has 5 positions, the indices are `0` to `4`, not `1` to `5`.
Common Mistake Checklist
After writing code, check this list.
- Did I forget any
;? - Do
(),[], and{}match? - Is input
cin >>, and outputcout <<? - Did I use
==when checking equality? - Did I declare each variable before using it?
- Did I stay inside the array range?
- If there are many test cases, did I reset the variables each time?
- Do I need a newline at the end of the output?
Do Not Rush Into Hard Notes
When you are just starting C++, your notes do not need to be full solution reports. You do not need to rush into these:
- Writing complete proofs.
- Memorizing many LaTeX math symbols.
- Copying every slide from class.
- Making every table look perfect.
The most important thing is that you can understand your own note after class.
Copy This Class Note Template
## Class X: Topic Name
### What I Learned Today
-
-
-
### Teacher's Example
```cpp
#include <iostream>
using namespace std;
int main() {
}
```
### My Own Small Change
What I changed:
```cpp
```
### What Confused Me Today
-
-
### Check Before Coding Next Time
- [ ] Did I forget any `;`?
- [ ] Did I write `cin` / `cout` in the correct direction?
- [ ] Do the brackets match?
- [ ] Does the output match the problem statement?
When You Want More Complete Notes
For syntax camp, keep notes simple and clear. Later, when you want to record more solution ideas, math formulas, tables, and table-of-contents links, read the full guide:
Summary
The point of syntax-camp notes is not to write a lot. The point is to write something you can understand later.
For each class, record "what I learned", "teacher's example", "what confused me", and "check before coding next time". That is already a useful class note.
快速目錄
- 這篇是給誰看的?
- 每堂課建議固定寫這 5 段
- Markdown 最常用的 6 個功能
- C++ 語法營常見筆記內容
- 常見錯誤檢查表
- 不用急著寫很難的東西
- 可以直接複製的上課筆記模板
- 之後想寫得更完整
- 小結
這篇是給誰看的?
這篇是給第一次參加 C++ 語法營 的同學看的。你可能剛開始學 cout、cin、變數、if、for 迴圈,還不熟競程,也還不需要寫很長的解題筆記。
語法營期間,你的筆記只要做到三件事就很好:
- 記得今天學了什麼。
- 留下一小段自己看得懂的 C++ 範例。
- 寫下今天卡住或容易忘記的地方。
筆記不是考卷,不需要一次寫得很完美。先寫得短、寫得清楚,之後再慢慢變完整。
每堂課建議固定寫這 5 段
你可以每堂課都用一樣的格式,這樣比較不會不知道要寫什麼。
## 第 1 堂:輸入輸出與變數
### 今天學到
- `cout` 可以輸出文字和數字。
- `cin` 可以讀入使用者輸入。
- `int` 可以存整數。
### 老師範例
```cpp
#include <iostream>
using namespace std;
int main() {
int age;
cin >> age;
cout << age << '\n';
}
```
### 我自己改的例子
把 `age` 改成 `score`,練習讀入分數。
### 今天卡住的地方
- 忘記每行結尾要加 `;`。
- `cin >> age;` 的箭頭方向常常寫反。
### 下次寫程式前先檢查
- [ ] 有沒有 `#include <iostream>`
- [ ] 有沒有 `using namespace std;`
- [ ] 有沒有 `int main()`
- [ ] 大括號 `{}` 有沒有成對
- [ ] 每行該加 `;` 的地方有沒有加
如果你不知道要寫什麼,就先照這個格式填空。
Markdown 最常用的 6 個功能
標題
標題可以把筆記分段。語法營筆記通常用 ## 和 ### 就夠了。
## 第 2 堂:if 判斷
### 今天學到
### 老師範例
### 今天卡住的地方
清單
清單適合記重點:
- `int`:整數
- `double`:小數
- `char`:一個字元
- `bool`:真或假
渲染:
int:整數double:小數char:一個字元bool:真或假
Checklist
checklist 適合當作寫程式前的檢查表:
- [ ] 變數名稱有沒有打錯
- [ ] `if` 條件有沒有寫在小括號裡
- [ ] 迴圈會不會跑太多次或太少次
- [ ] 輸出格式有沒有照題目要求
粗體
重要的地方可以用粗體:
**`=` 是指定,`==` 才是比較是否相等。**
渲染:
= 是指定,== 才是比較是否相等。
C++ 程式碼區塊
寫 C++ 範例時,請用三個反引號,並在後面加 cpp:
```cpp
int x;
cin >> x;
cout << x + 1 << '\n';
```
渲染:
int x;
cin >> x;
cout << x + 1 << '\n';
這樣程式碼會比較好讀,也比較容易看出哪裡少了符號。
表格
表格適合整理「語法、意思、例子」:
| 語法 | 意思 | 例子 |
|---|---|---|
| `int` | 整數 | `int n;` |
| `double` | 小數 | `double x;` |
| `char` | 一個字元 | `char c;` |
渲染:
| 語法 | 意思 | 例子 |
|---|---|---|
int |
整數 | int n; |
double |
小數 | double x; |
char |
一個字元 | char c; |
如果想讓某一欄置中,可以在分隔線加冒號:
| 語法 | 意思 | 例子 |
|:---:|---|---|
| `int` | 整數 | `int n;` |
: 放左邊是靠左,左右都放是置中,放右邊是靠右。
C++ 語法營常見筆記內容
變數
## 變數
變數像是一個有名字的盒子,可以放資料。
| 型別 | 可以放什麼 | 例子 |
|---|---|---|
| `int` | 整數 | `int age = 12;` |
| `double` | 小數 | `double height = 150.5;` |
| `char` | 一個字元 | `char grade = 'A';` |
| `bool` | 真或假 | `bool ok = true;` |
容易忘記:字元用單引號 `''`,例如 `'A'`。
if 判斷
## if 判斷
`if` 會先檢查條件,條件成立才做大括號裡的事情。
```cpp
int score;
cin >> score;
if (score >= 60) {
cout << "pass\n";
} else {
cout << "fail\n";
}
```
容易錯:
- 比較是否相等要用 `==`,不是 `=`。
- 條件要放在小括號 `()` 裡。
for 迴圈
## for 迴圈
`for` 可以把同一件事重複做很多次。
```cpp
for (int i = 1; i <= 5; i++) {
cout << i << '\n';
}
```
這段會印出 1 到 5。
我容易錯:
- `i++` 忘記寫,迴圈可能不會停。
- `i < n` 和 `i <= n` 要看題目需要幾次。
陣列
## 陣列
陣列可以存很多個同型別的資料。
```cpp
int a[5];
for (int i = 0; i < 5; i++) {
cin >> a[i];
}
```
注意:如果陣列有 5 個位置,編號是 `0` 到 `4`,不是 `1` 到 `5`。
常見錯誤檢查表
寫完程式後,可以回來看這張表。
- 有沒有少
; - 小括號
()、中括號[]、大括號{}有沒有成對 -
cin是>>,cout是<< - 比較相等有沒有寫成
== - 變數有沒有先宣告再使用
- 陣列有沒有超出範圍
- 如果題目有很多筆測資,有沒有每次都重新設定變數
- 輸出最後要不要換行
不用急著寫很難的東西
剛開始學 C++ 時,筆記不用寫成解題報告。下面這些先不用急:
- 不用寫很完整的證明。
- 不用記很多 LaTeX 數學符號。
- 不用把老師所有投影片都抄下來。
- 不用一次把表格排得很漂亮。
比較重要的是:你下課回家後,還看得懂自己今天學了什麼。
可以直接複製的上課筆記模板
## 第 X 堂:主題名稱
### 今天學到
-
-
-
### 老師範例
```cpp
#include <iostream>
using namespace std;
int main() {
}
```
### 我自己改的例子
我把哪裡改掉:
```cpp
```
### 今天卡住的地方
-
-
### 下次寫程式前先檢查
- [ ] 有沒有少 `;`
- [ ] `cin` / `cout` 方向有沒有寫對
- [ ] 括號有沒有成對
- [ ] 輸出格式有沒有照題目
之後想寫得更完整
語法營筆記先求簡單、清楚就好。等你開始想記更多解題想法、數學式、表格和目錄時,可以看完整版:
小結
語法營筆記的重點不是寫得多,而是寫得自己看得懂。
每堂課記下「今天學到」、「老師範例」、「我卡住的地方」、「下次檢查表」,就已經是一份很有用的上課筆記。