# 算術運算子
---
\+ 加
```cpp=
cout << 1+1 ;// 2
int a = 1;
int b = 2;
int c = a+b;//3
a += 3;//a = 4
b++;//b = 3
```
---
\- 減
```cpp=
cout << 1-1 ;// 0
int a = 2;
int b = 1;
int c = a-b;//1
a -= 3;//a = -1
b--;//b = 0
```
---
\* 乘
```cpp=
cout << 3*2 ;// 6
int a = 7;
int b = 3;
int c = a*b;//21
a *= 2;//a = 14
```
---
/ 除
```cpp=
cout << 3/2 ;// 1
int a = 7;
int b = 3;
int c = a/b;//2
a /= 2;//a = 3
```
餘數會直接不見
----
不想不見就要用浮點數
```cpp=
cout << 3/2.0 ;// 1.5
cout << (double)3/2 ;// 1.5
int a = 7;
int b = 2;
double c = (double)a/b;//3.5
a /= 2.0;//a = 3
c /= 5;//c = 0.7
```
---
% 餘
```cpp=
cout << 5%2 ;// 1
int a = 7;
int b = 3;
int c = a%b;//1
a %= 2;//a = 1
```
---
GJ a005
http://www.tcgs.tc.edu.tw:1218/ShowProblem?problemid=a005
----
tip
輸入間有空格時,會判斷為2個值
例如輸入"3 2"(沒有引號)
```cpp=
int a,b;
cin >> a >> b;//a = 3 b = 2
```
---
GJ a006
http://www.tcgs.tc.edu.tw:1218/ShowProblem?problemid=a006
---
GJ a007
http://www.tcgs.tc.edu.tw:1218/ShowProblem?problemid=a007
----
tip
```cpp=
cout << a << " " << b;
```
---
GJ a008
http://www.tcgs.tc.edu.tw:1218/ShowProblem?problemid=a008
----
tip
F=C*9/5+32;
---
GJ a009
http://www.tcgs.tc.edu.tw:1218/ShowProblem?problemid=a009
---
GJ a010
http://www.tcgs.tc.edu.tw:1218/ShowProblem?problemid=a010
{"metaMigratedAt":"2023-06-15T00:55:58.848Z","metaMigratedFrom":"YAML","title":"算術運算子","breaks":true,"slideOptions":"{\"transition\":\"slide\"}","contributors":"[{\"id\":\"9f6a1b41-e592-4580-9e63-5613e2cac6cb\",\"add\":1296,\"del\":28}]"}