---
# System prepended metadata

title: 函式
tags: [APCS與競賽入門]

---

# 函式

## C++常用內建函式

```cpp
#include<cmath>

double a,b;
pow(a,b);

long double a,b;
powl(a,b);
```

```cpp
int a,b,c;

max(a,b);
max({a,b,c});

min(a,b);
min({a,b,c});

swap(a,b);
```

```cpp
#include<algorithm>

int arr[100010];

fill(arr,arr+n,t);

sort(arr,arr+n);
nth_element(arr,arr+t,arr+n);
unique(arr,arr+n);

lower_bound(arr,arr+n,t);
upper_bound(arr,arr+n,t);
binary_search(arr,arr+n,t);

find(arr,arr+n,t);
find_if(arr,arr+n,t,cmp);

count(arr,arr+n,t);
count_if(arr,arr+n,t,cmp);

all_of(arr,arr+n,cmp);
any_of(arr,arr+n,cmp);
none_of(arr,arr+n,cmp);
```

## 自訂函式

## 習題

###### tags: `APCS與競賽入門`