Escolar Documentos
Profissional Documentos
Cultura Documentos
gr
http://creativecommons.
org/licenses/by-nc-sa/4.0/deed.el
https://www.materials.uoc.gr/el/undergrad/courses/ETY215/notes.pdf
1
advance()
next()
prev()
distance()
iterator_traits<>
accumulate()
inner_product()
partial_sum()
adjacent_difference()
min_element()
max_element()
minmax_element()
copy()
move()
copy_backward()
move_backward()
rotate()
rotate_copy()
replace()
replace_copy()
remove()
remove_copy()
unique()
unique_copy()
reverse()
reverse_copy()
random_shuffle()
shuffle()
partition()
stable_partition()
is_partitioned()
partition_point()
partition_copy()
sort()
stable_sort()
nth_element()
partial_sort()
partial_sort_copy()
is_sorted()
is_sorted_until()
lexicographical_compare()
next_permutation()
prev_permutation()
is_permutation()
find()
find_first_of()
search()
find_end()
adjacent_find()
search_n()
binary_search()
upper_bound()
lower_bound()
equal_range()
merge()
inplace_merge()
set_union()
set_intersection()
set_difference()
set_symmetric_difference()
includes()
make_heap()
is_heap()
is_heap_until()
pop_heap()
push_heap()
sort_heap()
all_of()
none_of()
any_of()
count()
equal()
mismatch()
iota()
for_each()
swap_ranges()
transform()
fill()
generate()
http://www.dmst.aueb.gr/dds/faq/academic.html#oo
#include <iostream>
/*
main:
Den pairnei orismata.
Zhta ena pragmatiko kai typwnei to tetragwno tou.
Epistrefei 0.
*/
int main()
{
std::cout << u8"Δώσε πραγματικό αριθμό: "; // Mhnyma sthn othoni
#include
#include <iostream>
<iostream>
#include
//
/* */
/* */
#if 0
.....
#endif
return 0;
0 0 main()
main() main()
double a;
double
double b;
"
u8
main()
'a' '1'
'\n'
u8
std::cin std::cout
std::cout << b;
std::cin >> a;
<<
std::cout
>> std::cin
<iostream>
\n
<<
b = a * a;
*
+= == << >>
/* //
//
#include <iostream>
main(){std:cout << 'Hello␣World!\n'}
int k;
decltype(a)
decltype
int i;
decltype(i) j;
std::array<>
=
0
auto
auto
std::initializer_list<>
=
auto
0 9
ena␣lathos␣onoma
double b, c;
b = 3.2;
c = 5.5;
c = c + 2.0 * b;
b=0
5.5+2.0*3.2 11.9
int a, b;
b = a = 3; //First a = 3; then b = 3;
int c = (b = 4) + a; // First b = 4; then c = 7;
int
short int long int long long int signed
unsigned float
double long double bool
char signed char
unsigned char wchar_t char16_t char32_t
void
<cstdint>
double_t float_t <cmath>
bool
int
int i;
short int int long int
long long int 16 16 32 64 bit
short int
using
int
long int long long int
char
sizeof()
signed unsigned
signed
int ! "
16 bit −215 , 215 − 1 =
[−32768, 32767]
std::numeric_limits<int>::min()
std::numeric_limits<int>::max()
<limits>
#include <limits>
#include <iostream>
int main()
{
std::cout << std::numeric_limits<int>::min() << '\n';
std::cout << std::numeric_limits<int>::max() << '\n';
}
int
<cstddef> std::size_t
using
0 x X
0x 0X
0b 0B
0 1
1'234'567'890
long int
long long int 12l long int
9223372036854775805L long long int
unsigned int
unsigned long int unsigned long long int
short int
+ -
float
double
long double
double g;
float
double
long double
double
std::numeric_limits<double>::digits10
std::numeric_limits<double>::min()
std::numeric_limits<double>::max()
<limits>
double
float
double long double
double
double
0 9
std::numeric_limits<>::min()
0 9
10
±yyy
×10±yyy
double
float long double
double
double
32.3f 3E-3F
float
long double
12.3456789
12.345′ 678′ 9
+ -
auto pi = 3.14159265358979323846f;
π 21 float
std::cout.precision(21);
21
6
bool
bool a;
true false
false
true
bool a{true};
bool
bool
true 1
false 0
true 0 false
nullptr true nullptr false
true
char
char c;
char
signed unsigned char
signed char unsigned char
char
char
8 bit
CHAR_BIT <climits>
char
'\0' 0
'0' 48
char c{'a'};
'a' '
"
char
char
'a'
97
char const *
char newline{'\n'};
char bell{'\a'};
char Alpha{'\x61'}; // Alpha = 'a' in ASCII, hex
char alpha{'\141'}; // alpha = 'a' in ASCII, octal
?
"
char16_t char32_t
16 32 bit
void
void * void
enum class
Color c{Color::red};
case
switch
0 0
1 2
int k{static_cast<int>(Color::green)};
5
enum class
Color g{static_cast<Color>(6)}; // g is Color::blue
class
enum
constexpr
constexpr
const
constexpr const
goto
#include
#include <iostream>
int main()
{ // begin block A
double x{3.2};
{ // begin block B
int x{5};
std::cout << x; // prints 5
} // end block B
std::cout << x; // prints 3.2
} // end block A
+ -
+ - *
%
int a{5};
int b{3};
int p{a/b}; // Piliko: p ← 1
int y{a%b}; // Ypoloipo: y ← 2
std::pow() <cmath>
xa std::pow(x,a)
#include <cmath>
=
a = a + b;
a += b;
+= -= *= /= %= =
1
++ --
b = ++a + c;
1
b = a++ + c;
1 1 --
b = --a + c;
a = a - 1;
b = a + c;
b = a-- + c;
b = a + c;
a = a - 1;
++ --
a--b (a--)b
a-(-b)
()
::
.
->
[]
()
{}
static_cast
const const_cast
++ --
sizeof
sizeof()
++ --
~
!
+ -
&
*
.*
->*
*
/
%
+ -
>> <<
< >
<= >=
== !=
&
&&
||
?:
{}
=
*=
/=
%=
+=
-=
<<=
>>=
&=
^=
|=
int double
int double
bool char
?:
int a = 3.14; // a is 3
short int b = 12121212121.3; // b = ??
static_cast<>
int sum{2 + 3 + 5};
int N{3};
double mean1{sum / N}; // Wrong value
double mean2{static_cast<double>(sum) / N}; // Correct value
static_cast<>
static_cast
static_cast<>
static_cast<>
double mean2{1.0 * sum / N};
sizeof
sizeof
int a;
std::cout << sizeof(int); //parentheses are necessary
std::cout << sizeof(a);
std::cout << sizeof a;
sizeof
sizeof std::size_t
enum class
~
0 1
compl
<< >>
<<
0 >> unsigned
=
char
~ ~expr
<< expr1 << expr2
>> expr1 >> expr2
& expr1 & expr2
^ expr1 ^ expr2
| expr1 | expr2
<<= expr1 <<= expr2
>>= expr1 >>= expr2
&= expr1 &= expr2
^= expr1 ^= expr2
|= expr1 |= expr2
& ^ |
std::bitset<>
std::vector<> bool std::vector<bool>
bool
,
auto a = -1;
auto b = 1;
std::cout << a, b << '\n';
std::cout << (a, b) << '\n';
double sqrt(double x)
std::sqrt()
<cmath>
y=std::sqrt(x);
int main()
{
double x;
std::cin >> x;
auto y = std::sqrt(x);
'\n'
10
std::cout << y << '\n';
}
<complex>
#include <complex>
<complex>
std::complex_literals
i
std::complex<double> 0
i if il
1i
0.0 + 1.0i
using namespace std::complex_literals;
double
std::complex<double> z; // z = 0.0 + 0.0 i
double
float long double
0 + 0i
std::array<>
std::complex<double> z(3.4,2.8);
0
std::complex<double> z{3.41}; // z = 3.41 + 0.0i
std::complex<double> z(3.41);
std::complex<double> z = 3.41;
0
std::complex<double> z{1.2i}; // z = 0.0 + 1.2i
+ - * / += -= *= /=
std::abs()
<complex>
std::abs()
z = α + iβ
std::complex<double>
std::vector<double> double
<complex>
√ #
std::abs(z) zz⋆ → α2 + β 2
std::polar()
0 std::polar(r,t)
z = reit std::polar(r)
z = rei0 ≡ r(1 + 0i) = r
std::norm()
z = α + iβ
std::norm(z) zz⋆ → α2 + β 2
std::arg()
z = α + iβ
std::conj()
z = α + iβ
std::conj(z) → α − iβ
std::proj()
std::real()
z = α + iβ
std::real(z) → α
real() std::complex<>
z.real()
std::imag()
z = α + iβ
std::imag(z) → β
imag() std::complex<>
z z.imag()
real()
imag()
std::complex<double> z{3.0,1.5}; // z = 3.0 + 1.5i
z.real(4.2); // z = 4.2 + 1.5i
z.imag(-0.9); // z = 4.2 − 0.9i
<<
std::complex<double> z{3.2,1.5};
std::cout << z;
(3.2,1.5)
>>
std::complex<double> z;
std::cin >> z;
char
std::string <string>
std::string
std::string s;
std::string
std::string s{};
std::string
u8
char
string
std::string s1{"Giver␣number:"};
std::string s2{s1}; // s2 <- "Give number:"
string
std::string s1{"Give␣number:"};
std::string s2{std::move(s1)};
// s2 <- "Give number:", s1 undefined
string
std::string s1{"Give␣number:"};
// copy all chars from position 3
std::string s2{s1,3}; // s2 <- "e number:"
string
std::string s1{"Give␣number:"};
// copy 5 bytes from position 3
std::string s2{s1,3,5}; // s2 <- "e num"
int n{6};
std::string s(n, '*'); // s <- "******"
= string
string
std::string std::wstring
std::u16string std::u32string
wchar_t char16_t char32_t
using
using
using
std::complex<double>
complex
complex z;
using
double
double float
real
using typedef
typedef
using
typedef
using
namespace
namespace onoma {
...
double a;
...
}
namespace
namespace
onoma::a namespace
namespace
namespace
n1::n2::a
std::
#include <iostream>
#include <complex>
int main()
{
using namespace std; // "std::" not needed below
complex<double> a{2.4,3.7};
cout << a << '\n';
}
using namespace std;
namespace
using std::cout;
cout
#include <iostream>
#include <complex>
int main()
{
using std::cout;
std::complex a{2.4,3.7}; // std:: necessary
cout << a << '\n'; // std:: not necessary
}
namespace {
...
}
namespace
#include
namespace
main()
int a;
int a;
int & r{a};
a = 3; // r = 3
r = 2; // a = 2
int b{a}; // b = 2
int c{r--}; // c = 2, a = 1
const constexpr
const
int constexpr a{5};
int & p{a}; // Error
int const & q{a}; // Correct. Value of a cannot change through q.
std::numeric_limits<double>::digits10
<limits>
#include <limits>
#include <iostream>
int main()
{
auto const & digits = std::numeric_limits<double>::digits10;
std::cout << digits << '\n';
}
int a{3};
int b{4};
int c{a+b};
a+b
int a{3};
int b{4};
int c{a+b};
int && d{a-b};
d = 6;
&&
a-b
std::move() <utility>
auto c = a;
a = b;
b = c;
auto c = std::move(a);
a = std::move(b);
b = std::move(c);
auto x = y;
auto z = std::move(y);
x = y;
z = std::move(y);
std::move()
&
int a{3};
&a
int
int * p{&a};
*
*p
*p
double r{5.0};
double * q{&r};
*q = 3.0; // r becomes 3.0
int a{4};
int * p;
p = &a;
int * q{p};
*q *p
void
int a{5};
int * p{&a};
void * t{p};
void int
*
*
void static_cast<>
int * v{static_cast<int*>(t)};
*v = 4;
4
void *
static_cast<>
*
nullptr
nullptr
int a;
int * p1{&a};
int const * p2{&a};
int * const p3{&a};
int const * const p4{&a};
int * & p5{p1};
int const * & p6{p2};
int * const & p7{p3};
int const * const & p8{p4};
*p2
*p3
double x{1.2};
double * const p{&x};
double y{0.1};
p = &y; // error
double const * q{&x};
*q -= 0.2; // error
int const a{2};
int * r{&a}; // error
*p
++ --
sizeof
sizeof(T)
p+2
sizeof(T)
+= -=
sizeof(T)
sizeof(T)
int a{4};
int *p{&a};
int *q{&a+10};
auto k = q - p; // int k = 10;
void
std::ptrdiff_t <cstddef>
void * void
<cstdlib>
std::rand() <cstdlib>
std::rand()
RAND_MAX RAND_MAX
<cstdlib>
#include <cstdlib>
int main()
{
auto r = std::rand(); // r is random in [0,RAND_MAX]
... // use r
}
std::rand()
std::time()
1 1970
std::rand()
std::srand(std::time(nullptr));
[m, n] m n
= αr + β α
β
[m, n]
std::rand()
static_cast<double>(r) / RAND_MAX [0, 1]
[a, b]
double x{a + static_cast<double>(std::rand()) / RAND_MAX * (b-a)};
<random>
<random>
[5, 20]
std::default_random_engine
std::uniform_int_distribution<int>
d(e)
#include <random>
int main()
{
std::default_random_engine e{};
std::uniform_int_distribution<int> d{5, 20};
std::random_device
#include <random>
int main()
{
std::random_device rd{};
std::default_random_engine e{rd};
std::uniform_int_distribution<int> d{5, 20};
std::uniform_int_distribution<int> <random>
[a, b)
std::uniform_real_distribution<double>
std::uniform_real_distribution<double> d{a,b};
b b>a
std::normal_distribution<double>
std::normal_distribution<double> d{m,s};
#include <iostream>
int main()
{
std::cout << u8"Δώσε δυο ακέραιους\n";
int a, b;
std::cin >> a >> b;
int c{a + b};
std::cout << u8"Το άθροισμά τους είναι: " << c << '\n';
}
x
y z
x2 + y 2 + z 2
x2 /y + z
2.45(x + 1.5) + 3.1(y + 0.4) + 5.2 − z/2
(12.8x + 5y)/(11.3y + 4z)
x2/3 + y 2/3 + z 2/3
a b c a2 +b2 = c2
m n m>n
a= m2 − n2 b = 2mn c = m2 + n2
10
200000
30 360
2034938471
2099
r1 19
r2 4
r3 7
ra = 19r1 + 16
r4 ra 30
rb = 2(r2 + 2r3 + 3r4 )
r5 rb 7
rc = r4 + r 5
rc
rc
5^2
int m{217};
int n{813};
m ^= n;
n ^= m;
m ^= n;
80 cm
cm
km m cm
1253
100 240 cm 1 km 2 m 40 cm
π = cos−1 (−1) ,
π = 8 tan−1 (1/3) + 4 tan−1 (1/7) ,
√ √
4 sin(π/12) = 6− 2,
tan(π/2) = ∞ .
π
∞ = 1/0
π 3.14159265358979323846264338 . . .
15
std::cout.precision(16); 16
q1 q2
(x1 , y1 , z1 ) (x2 , y2 , z2 )
q1 q2 x2 − x 1 q1 q2 y2 − y1 q 1 q 2 z 2 − z1
Fx = , Fy = , Fz = ,
4πϵ0 d3/2 4πϵ0 d3/2 4πϵ0 d3/2
x>10 a!=b
> >=
< <=
== !=
!
&&
||
not and or
&& ||
!
!
&& ||
||
&&
|| &&
bool
bool a{3==k};
auto b = ( i > 0 && i < max );
true
false
i < max
if
else
if
if
else else if
if (i == 0)
if (val > max)
max = val;
else
max = 10;
max = 10;
(i == 0) (val > max) (i == 0)
if (i == 0) {
if (val > max)
max = val;
}
else
max = 10;
if
bool
if
else
if (int j = 3) {
max = 10 + j;
}
3 true
if
if (j = 3) {
max = 10 + j;
}
3 true
if (j == 3) {
max = 10 + j;
}
?:
if (condition) {
val = value1;
} else {
val = value2;
}
(k == 5 ? a : b) = 3;
5
a=3;
b=3;
= += -= *=
/= ?: =
a = b ? c : d a = (b ? c : d)
a ? b : c = d a ? b : (c = d)
true
switch
if
switch (i) {
case value1:
...
case value2:
...
...
case valueN:
...
default:
...
}
bool
enum class
enum class
case
case default break
goto return throw
switch
default
switch
case default
#include <iostream>
int main()
{
double a, b, res;
char c;
std::cin >> a >> b;
std::cin >> c;
switch (c) {
case '+':
res = a + b;
break;
case '-':
res = a - b;
break;
case '*':
res = a * b;
break;
case '/':
res = a / b;
break;
default:
std::cerr << "wrong␣character\n";
return -1;
}
std::cout << "the␣result␣is␣" << res << '\n';
}
case
0 1 2
4 5
switch (i) {
case 0:
case 1:
case 2:
....
break;
case 4:
case 5:
....
break;
}
2 0
ax = b
a, b
a, b a ̸= 0
a=0 b=0 a=0 b ̸= 0
ax2 + bx + c = 0 a, b, c
abc
2015
48000 20000
22 4400 10000
29 2900 10000
37 3700 8000
45 3600 14600
d 1, 2, 3, . . . , 31 m 1, 2, . . . , 12 y
1 2
m 12 1 y
a 13(m + 1) 5
j, k
100
b j 4
c k 4
h a b c d k
j
h 7 0
1
31
30
28
29
4
400 4
100 400
16
1923 1 1923
1923 15
switch
1
2 3 4 5
500
int i{1};
std::cout << i << '\n';
i = 2;
std::cout << i << '\n';
i = 3;
std::cout << i << '\n';
i = 4;
std::cout << i << '\n';
i = 5;
std::cout << i << '\n';
1
for
range for while do while for while do while
break
for
500
for
while do while
int i{1};
while (i <= 5) {
std::cout << i << '\n';
++i;
}
int i{1};
do {
std::cout << i << '\n';
++i;
} while (i <= 5);
for
goto
for
for
for
for
for
for
for (int i{1}; i <= 5; ++i) {
std::cout << i << '\n';
}
1
5
for
1 9
int s{0};
s += 1;
s += 3;
s += 5;
s += 7;
s += 9;
int s{0};
int i{1};
s += i;
i += 2;
s += i;
i += 2;
s += i;
i += 2;
s += i;
i += 2;
s += i;
for
int s{0};
for (int i{1}; i<=9; i+=2) {
s += i;
}
i+=2;
int i;
for
int s{0};
int i{1};
for ( ; i<=9; i+=2) {
s += i;
}
for 11
for
for
while do while
100 1 100
int s{0};
for (int i{1}; i<= 100; ++i) {
s += i;
}
[0, 1000]
int s{0};
for (int i{0}; i<= 1000; i+=2) {
s += i;
}
99 97 95 3 1
double s{0.0};
for (double x{0.0}; x <= 0.3; x += 0.1) {
s += x;
}
2 3
[5, 108]
int k{0};
for (int i{5}; i <= 108; ++i) {
if (i%2 == 0 || i%3 == 0) {
++k;
}
}
0
0 1 1 2 3 5 8 13
−2
c=a+b;
int a{0};
int b{1};
std::cout << a << '\n' << b << '\n';
for (int k{2}; k <= n; ++k) {
int c{a+b};
std::cout << c << '\n';
a = b;
b = c;
}
j
$
ak ,
k=i
k i j
ak k
i j
double s{0.0};
for (int k{i}; k <=j; ++k) {
s += ak;
}
ak ak
s
for
0
j
%
ak ,
k=i
double p{1.0};
for (int k{i}; k <=j; ++k) {
p *= ak;
p
1
for
for (auto x : a) {
.... // use value of x
}
for
range for
4 5 8 −6
for (auto x : {4,5,8,-6}) {
std::cout << x << '\n';
}
range for
while
while
while
0
int i;
std::cin >> i;
int s{0};
while (i != 0) {
s += i;
std::cin >> i;
}
do while while
do
while
do while
int i;
do {
std::cout << u8"Δώσε θετικό ακέραιο: ";
std::cin >> i;
std::cout << '\n';
} while (i <= 0);
break switch
for range for while do while
int i;
while (true) {
std::cout << u8"Δώσε θετικό ακέραιο: ";
std::cin >> i;
std::cout << '\n';
if (i > 0) {
break;
}
std::cerr << "Έδωσες αρνητικό\n";
}
// ... use i
true
do {...} while (true);
for (;;) {...}
continue for
for while do while
10
labelname : statement;
`:'
goto
goto labelname;
goto
goto
catch
goto
goto
switch
goto break
goto
0.0 0.1 0.2
0.3 0.4 2.5
20 2 20 21 219
n! = 1 × 2 × 3 × . . . × n, 0! = 1.
12
⎧
⎪
⎨ 1 × 3 × 5 × · · · × (n − 2) × n n
n!! = 2 × 4 × 6 × · · · × (n − 2) × n n
⎪
⎩ 1 n 0
15
53 [−3.5, 6.5]
n [a, b]
h x1 = a x2 = a + h x3 = a + 2h xn =
a + (n − 1)h xn ≡ b h = (b − a)/(n − 1)
30
f (x) = x(x2 + 5 sin(x)) [−5, 5]
1000
0.5
15
2011 10815197
0.53
15000000
ab
a b
a<b
b=0 a
b > 0
b a b
135 680
6
1 2 3 6 1+2+3+6 = 12 = 2×6
4
444
3
3
fi+2 = fi+1 + fi , i ≥ 0, f0 = 0, f1 = 1 .
0, 1, 1, 2, 3, 5, 8, . . .
n
0 ≤ n < 31
http://en.wikipedia.org/wiki/Euclidean_algorithm
http://oeis.org/A000045
1
18
1930
8/2/2013
17000
26/8/2059
13000 2/7/2015
28/11/1979
1/1/1970 00 00 00
109
231 − 1
9/9/2001 01 46 40 19/1/2038 03 14 07
1950
ex sin x cos x
∞ n
$ ∞
$ ∞
$
x (−1)n x2n+1 (−1)n x2n
ex = , sin x = , cos x = .
n=0
n! n=0
(2n + 1)! n=0
(2n)!
10−10
a
2a = n(n + 1) + m(m + 1) + k(k + 1)
nmk
a
nmk
nmk
n≤m≤k
16 [0, 1, 5] [0, 3, 4] [2, 2, 4] 104 [2, 4, 13]
111 [1, 10, 10] [0, 9, 11]
∞
%
π 4n2
= .
2 n=1 4n2 − 1
104
π/2
http://mathworld.wolfram.com/LagrangesFour-SquareTheorem.html
∞
* + ,-
$ 12 9 π2
cos # =−
n=1
n2 nπ + (nπ + 3)(nπ − 3) e3
10−7
∞
$ 1
ln(5/4) =
k=1
k5k
10−11
π
∞
$ (−1)k
π=3 .
k=0
(k + 1/2)3k+1/2
10−8
π
= lim fn ,
4 n→∞
.
n / 02
1$ k
fn = 1− .
n k=1 n
n fn π/4
fn n = 106 π/4
2
0
p p + 6 p + 12
10000
120
[−100, 100]
<random>
∞
$ k(5k + 3)(2k − 1)!k!
π =3+2 .
k=1
2k−1 (3k + 2)!
π
10−6
10−6
65728
64232
k k = i3 + j 3
i, j i, j, k i≤j<k
1729 = 13 + 123 = 93 + 103
http://oeis.org/A047948
https://en.wikipedia.org/wiki/Taxicab_number
3 = 1 + 2 × 12
5 = 3 + 2 × 12
9 = 1 + 2 × 22 = 7 + 2 × 12
15 = 7 + 2 × 22
27 = 19 + 2 × 22
=
n
1 n 3142
4
[6, 10000]
529 925
910 19
100
12 2×6
3×4 2×2×3
1
12 223
13 13
1 b
f (x) dx ,
a
f (x)
a b
(xi , yi ) a ≤ x ≤ b
0 ≤ y ≤ max{f (x)} xi yi max{f (x)}
f (x) [a, b] y = f (x)
yi ≤ f (xi )
a≤x≤b 0≤y≤
max{f (x)}
1 2
x2 dx .
0
<random>
1 2 5 10 20
50 100 =1 200 =2
300
300
150 60 5
300
std::array<>
<array> std::vector<> <vector>
struct
class
std::array<> std::vector<>
std::array<>
std::vector<>
std::array<>
std::vector<>
std::array<> <array>
std::array
constexpr
constexpr
std::array<double,7> temper;
<array> #include
int constexpr n{5};
std::array<double,n> a, b;
5
std::array<>
0
std::array<char,4> letter{'a', 'b', 'c', 'd'};
// letter[0] = 'a', letter[1] = 'b', letter[2] = 'c', letter[3] = 'd'
std::array<int,5> a{1,2,5,7,8};
std::array<int,5> b{a};
auto c = a;
0 −1
0 1 −1
0
−1
std::array<double,7> temper;
temper[0] temper[1]
temper[6]
temper[4] = 13.6;
temper[5] = 15.0;
temper[6] = 16.5;
std::array<double,7> temp;
... // give values to temp
temper = temp;
fill()
temper.fill(12.6);
12.6
std::array<>
std::array<>
15
double a[15];
std::array<>
int a[10];
int * p{&a[3]};
int * q{p + 2}; // q == &a[5]
std::array<> std::vector<>
int a[10];
int * p{&a[0]};
*(p+i) a[i]
p+i == &a[i]
a[i]
*(a+i)
double b[10];
double * p{b};
for (int i{0}; i < 10; ++i) {
*p = 1.0;
++p;
}
double b[10];
for (auto p = b; p != b+10; ++p) {
*p = 1.0;
}
sizeof
double a[13];
int k { sizeof(a) / sizeof(a[0]) }; // k == 13
std::array<> std::vector<> <vector>
std::array<>
#include <vector>
#include <iostream>
int main()
{
int D;
std::cin >> D; // get dimension
std::vector<double> v(D);
...
}
std::vector<>
std::array<>
std::vector
std::vector<>
0
std::vector<>
std::array<> v[0] v[1]
std::vector<>
std::vector<>
std::array<>
std::array<>
std::vector<>
std::malloc()
void
static_cast<>
std::free()
void *
#include <cstdlib>
#include <cstddef>
int main()
{
std::size_t D;
std::cin >> D; // get dimension
auto p = std::malloc(D * sizeof(double));
double * v{static_cast<double *>(p)};
v[0] = ...
v[1] = ...
...
v[D-1] = ...
std::free(p);
}
std::malloc()
sizeof
double
std::free()
new/delete[]
int main()
{
std::size_t D;
std::cin >> D; // get dimension
v[0] = ...
v[1] = ...
...
v[D-1] = ...
delete[] v;
}
2 3
(◦C)
1 5.0
2 7.5
3 6.4
157 19.1
158 21.4
364 4.5
365 7.0
1 365
1 2 ... 14 15 . . . 30 31
1 5.0 7.5 . . . 8.3 9.2 . . . 12.3 11.0
2 4.5 6.5 . . . 7.0 9.0 . . .
std::array<> std::array<>
std::array<std::array< >, >
12
31
std::array<std::array<double,31>,12> tempr;
<array>
14
tempr[3][13]
0
(i, j) tempr[i,j]
tempr[i,j] j
std::array<double>
std::array<std::array<int,3>,2> b { 0, 1, 2, 3, 4, 5 };
+ ,
0 1 2
b= .
3 4 5
std::array<>
[1][29] [5][30]
12 31
double tempr[12][31];
tempr[3][13] = 16.5;
tempr[i,j] (0, j)
(i, j)
std::array<>
3
4 0, 1, 2 0, 1, 2, 3
0
(0, 0)
(i, j) i+3∗j
M N
k = i+M ∗j
(i, j) k = i∗N +j
M ×N
M ∗N (i, j)
0 1 2 3
i+M ∗j i∗N +j
M ×N
k
k
std::vector<>
[aij ] ×
D1*D2 aij a[i+D1*j]
a[i*D2+j]
[aijk ] × ×
D1*D2*D3 aijk
a[i+D1*(j+D2*k)]
a[i+D1*(j*D3+k)]
a[(i*D2+j)*D3+k]
a[(i+j*D1)*D3+k]
std::array<> std::vector<>
8 6
std::array<double,8*6> b;
5 2 b[4+8*1]
const constexpr
std::array<> std::vector<>
size() a.size()
size()
std::vector<>
size() 0
std::array<double,10> a;
for (std::size_t i{0}; i < a.size(); ++i) {
std::cin >> a[i];
}
5×8
std::array<std::array<int,8>,5> a;
for (sts::size_t i{0}; i < 5; ++i) {
for (std::size_t j{0}; j < 8; ++j) {
std::cin >> a[i][j];
}
}
std::array<int,5*8> a;
for (std::size_t i{0}; i < 5; ++i) {
for (std::size_t j{0}; j < 8; ++j) {
std::cin >> a[i+5*j];
}
}
a[i+D1*j]
std::array<int,5*8> a;
... // give values to a
for (std::size_t k{0}; k < a.size(); ++k) {
std::cout << a[k] << '\n';
}
std::array<int,5*8> a;
... // give values to a
for (auto const & x : a) {
std::cout << x << '\n';
}
a[i*D2+j] a[i+D1*j]
std::string
struct
struct {
};
struct
struct ChemicalElement {
double mass;
int Z; // atomic number
std::string name;
std::string symbol;
};
ChemicalElement hydrogen;
""
.
.
ChemicalElement oxygen;
oxygen.name = "Oxygen";
oxygen.mass = 15.99494;
oxygen.Z = 8;
oxygen.symbol = "O";
std::cout << "The␣mass␣of␣element␣" << oxygen.name
<< "␣is␣" << oxygen.mass << '\n';
* .
(*p).member
p->member
struct
100
i i = 0, . . . , 99 i2 +3i+1
N
j j = 0, . . . , N − 1 sin(πj/N )
0.4
A B
20×30 (i, j) i = 0, . . . , 19 j = 0, . . . , 29 A
(i + j)/3 B(i, j) 2i − j/3
BT B
A, B T
A · BT
a 100 j j=
0, . . . , 99 cos(πj/100)
50 50 a[0] ↔ a[50] a[1] ↔ a[51]
a[49] ↔ a[99]
0 12 ex
x
std::exp() <cmath>
π
∞
$
1 ((2n)!)3 (42n + 5)
= ,
π n=0 (n!)6 163n+1
15
3.1415926535898
AM ×N BN ×P Aij Bij CM ×p
$
N
1000
2
2 1000
n
1, 2, 3, . . . , n
n
i
i
n
M ×N M = 20 N = 60 K = 400
1 0 1
'x' 'o'
9×9
std::cin std::cout
std::cerr std::clog
wchar_t
std::wcin std::wcout std::wcerr std::wclog
<iostream>
<fstream>
ifstream ofstream
std::ifstream inpstr{"filename"};
std::ofstream outstr{"filename"};
std::cin
std::cout
double a{10.0};
outstr << a;
char c;
inpstr >> c;
str.close();
str.open("filename");
<sstream>
std::istringstream std::ostringstream
ostringstream
"filename_3.dat"
#include <sstream>
int main()
{
std::ostringstream os;
os << "filename_";
os << 3;
os << ".dat";
// os contains the string "filename_3.dat"
}
str()
ostringstream
std::cout << os.str(); // prints: filename_3.dat
std::ostringstream
std::ofstream outstr{os.str()};
std::istringstream
#include <sstream>
int main()
{
std::istringstream is{"5␣6␣7␣a"};
int i,j,k;
is >> i; // i = 5
is >> j; // j = 6
is >> k; // k = 7
char ch;
is >> ch; // ch = 'a'
}
<<
std::cout << 'a';
std::cerr << "Wrong␣value␣of␣b\n";
std::cin >>
double a;
int b;
std::cin >> a;
std::cin >> b;
<< >>
std::cout << u8"Το άθροισμα του " << a << u8" και του " << b
<< u8" είναι: " << a+b << '\n';
bool
std::noboolalpha
bool
false
while
int i;
while (inp >> i) {
...
}
inp >> i
true while
get()
EOF eof()
true
seekg() seekp()
is.seekg(0);
std::boolalpha std::noboolalpha
bool <ios>
std::noskipws std::skipws
std::skipws
std::noshowpos std::showpos +
std::noshowpos
std::noshowpoint std::showpoint
std::setprecision()
std::noshowpoint
std::scientific d.ddddddedd
std::fixed dddd.dd
std::defaultfloat
std::left std::right
std::setw()
std::right
<iomanip>
std::setprecision()
std::fixed std::scientific
std::defaultfloat std::setprecision()
std::setw()
0
std::setfill()
std::setw()
␣
std
#include <ios>
#include <iomanip>
#include <iostream>
int main()
{
double b{3.25};
std::cout << b << '\n';
std::cout << std::showpoint << b << '\n';
std::cout << std::noshowpoint; // reset
double a{256.123456789987};
std::cout << "default\t" << a << '\n';
std::cout << "scientific\t" << std::scientific << a << '\n';
std::cout << "fixed\t" << std::fixed << a << '\n';
std::cout << "with␣9␣digits\t" << std::setprecision(9)
<< a << '\n';
}
int main()
{
std::cout.precision(9);
std::cout << 256.123456789987 << '\n'; // 256.123457
std::cout << std::fixed;
std::cout << 256.123456789987 << '\n'; // 256.123456790
}
0◦ 359.9◦ 0.1◦ 5
x0
(0, 1)
x1
x2 x100
x1 = |(100 ln(x0 )) mod 1| ,
x2 = |(100 ln(x1 )) mod 1| ,
2014
[0, 1)
1.0
9.9 0.1 3
i
j
(i, j)
n×n
P (i, 1) = P (1, j) = 1 i j
P (i, j) = P (i − 1, j) + P (i, j − 1) i, j > 1
n=7
2
3
1
1
n
2
100000
1
10000
[−20, 20]
http://tinyurl.com/ints201406 1300
m 7 999999
p q m = p + 2q m p q
θi
r(θi ) (θi , r(θi ))
n 0 ≤ n < 106
137n
http://bit.ly/2bDuQxB http://bit.ly/2bIIhtv
1200 1600
http://tinyurl.com/q8cuydn 4996
http://tinyurl.com/q8cuydn 4996
0 1
0
1
70
512 × 512
1
0
K
256
255
0 K
70
(i, j)
(i, j)
p (i, j)
(i ± p, j ± p) (i, j)
p
http://fla.st/
1KxdatB
K 255
255
K 0 0 K 255
255 0 0
0 K 0 0 0 0 K K K
K K 0
0 K
70
512 × 768
M ×N
K
http://www.math.com/students/wonders/life/life.html
animate
*.ppbm
128 × 128
(64, 64)
90◦
90◦
12000
100
http://mathworld.wolfram.com/LangtonsAnt.html
main()
main()
f (x) = x2 + 5x − 2 .
x2 + 5x − 2
f
x
f (x) f
x x
x2 + 5x − 2
x
f x
y = f (2.5)
y = 2.52 + 5 × 2.5 − 2
x x
auto
->
auto
decltype(auto)
void
return
return
return
void
return
main() return
return 0;
return
void
return;
void return
void f(int a)
{
// ...
return;
}
void g(int b)
{
return f(b);
}
return
->
#include
read()
#include <iostream>
#include <fstream>
#include <string>
//declarations
double func(double a, double b); // The definition is elsewhere.
int read(double & a, std::string const & fname);
void print(char c);
// definition
int read(double & a, std::string const & fname)
{
std::ifstream file{fname};
file >> a;
return 0; // All ok
}
// definition
void print(char c)
{
std::cout << c << '\n';
}
int main()
{
double x{3.2};
double y{3.4};
double z{func(x,y)}; // Calls func with double, double.
int i{3};
double t{func(x,i)}; // Calls func with double, int.
// int is promoted to double.
double r;
read(r, "input.dat");
// Calls function and ignores returned value.
}
#include <iostream>
int main()
{
double z{2.0};
add3(z); // z = ???
std::cout << z << '\n'; // z is 2.0
}
void add3(double x)
{
x+=3.0;
}
add3()
2.0 5.0
2.0
add3(z)
add3(&z)
*x
const
const
2
1 × 2 × · · · × (n − 1) × n = (n − 1)! × n , n > 0 ,
n! =
1, n=0.
−1 =1
int factorial(int n)
{
int result;
if (n > 0) {
result = n * factorial(n-1);
}
if (n == 0) {
result = 1;
}
return result;
}
factorial()
factorial(n)→factorial(n-1) →factorial(n-2)→ . . .
?:
int factorial(int n)
{
return (n > 0 ? n * factorial(n-1) : 1);
}
H0 (x) = 1 ,
H1 (x) = 2x ,
H2 (x) = 4x2 − 2 ,
H3 (x) = 8x3 − 12x ,
Hn (x)
H0 (x) = 1
H1 (x) = 2x
H1 (x)
H2 (x) H3 (x)
Hn (x) x
if (n == 0) {
h = 1.0;
}
if (n == 1) {
h = 2.0 * x;
}
if (n > 1) {
h = 2.0 * (x * hermite(n-1,x) - (n-1) * hermite(n-2,x));
}
return h;
}
const
*xp
void f(double const * xp);
// argument cannot change, *xp cannot change
*xp
void f(double * & xp);
// argument can change, *xp can change
5.0
f (x)
(x, y)
#include <iostream>
return 0;
}
plot()
f(x) f(x)
plot()
*
()
fptr = f; // assignment
double x{1.2};
auto y = f(x);
auto z = fptr(x); // or z = (*fptr)(x);
// y == z
return 0;
}
f(x) f (x)
(*f)(x)
int main()
{
plot(1.0, 5.0, mysin); // plot of mysin
plot(1.0, 5.0, mycos); // plot of mycos
plot(1.0, 5.0, mytan); // plot of mytan
}
int main()
{
plot(1.0, 5.0, mysin); // plot of mysin
plot(1.0, 5.0, mycos); // plot of mycos
plot(1.0, 5.0, mytan); // plot of mytan
}
using
<functional>
std::function<> <>
return 0;
}
plot()
double mysin(double x);
double mycos(double x);
double mytan(double x);
int plot(double low, double high, std::function<double (double)> f);
int main()
{
plot(1.0, 5.0, mysin); // plot of mysin
plot(1.0, 5.0, mycos); // plot of mycos
plot(1.0, 5.0, mytan); // plot of mytan
}
std::function<>
.h
#include "name.h"
"
<>
<
<
double
// utilities.h
double min(double a, double b); // declaration
double max(double a, double b); // declaration
// utilities.cpp
#include "utilities.h"
// Not necessary but good practice
// definitions
double min(double a, double b)
{
return a<b ? a : b;
}
#include <iostream>
#include "utilities.h"
int main()
{
double a, b;
std::cout << "Give␣two␣real␣numbers\n";
std::cin >> a >> b;
std::cout << "Max␣is␣" << max(a,b) << '\n';
std::cout << "Min␣is␣" << min(a,b) << '\n';
}
main()
main()
int main() {.....}
1 main() 0
char
argv[0]
argv[1] argv[2]
argv[argc] 0
argv[0] = "./a.out";
argv[1] = "12";
argv[2] = "input.dat";
argv[3] = "output.dat";
argv[4] = "4.5";
argv[5] = 0;
1 4
main()
<cstdlib>
int atoi(char const * p); // C-string to int
long atol(char const * p); // C-string to long int
double atof(char const * p); // C-string to double
strtol() strtod()
#include <cstdlib>
#include <fstream>
std::ifstream filein{argv[2]};
// open input file. Name is given by argv[2].
std::ofstream fileout{argv[3]};
// open output file. Name is given by argv[3].
double x{std::atof(argv[4])};
// x gets the value of the fourth argument
....
}
std::swap() <utility>
...
double a{2.0};
double b{3.0};
swap<double>(a,b);
swap(a,b)
enum class
bool mult(int a, int b)
{
return !(a%b);
}
mult(a,b)
template<int b>
bool mult(int a)
{
return !(a%b);
}
mult<b>(a)
swap()
swap()
template<>
void swap(int & x, int & y)
{
if (&x != &y) {
x^=y;
y^=x;
x^=y;
}
}
swap<int>(a,b)
typename T
template<typename T1>
void f(T1 a, int b)
{
...
}
template<typename T2>
void f(double a, T2 b)
{
...
}
constexpr
constexpr
constexpr
goto try
constexpr
constexpr
int max(int a, int b)
{
return a > b ? a : b;
}
constexpr
constexpr
int factorial(int n)
{
return (n > 0 ? n * factorial(n-1) : 1);
}
constexpr
constexpr
inline
inline
int max(int a, int b)
{
return a > b ? a : b;
}
inline main()
constexpr
inline
static
void func(double a)
{
static int howmany{0};
// .....
++howmany;
}
func()
static
std::abort()
<cmath>
float double long double
double <cmath>
std
<cstdlib>
std
int abs(int x)
std::div_t
quot rem long int long long int
std::ldiv_t std::lldiv_t
double
lldiv_t div(long long int n, long long int d);
<cinttypes>
intmax_t imaxabs(intmax_t x);
imaxdiv_t imaxdiv(intmax_t n, intmax_t d);
std::intmax_t <cstdint>
std::imaxdiv_t std::intmax_t quot
rem
<cmath>
[−π, π] rad
double cosh(double x)
double sinh(double x)
double tanh(double x)
double acosh(double x) ≥ 1
double asinh(double x)
double atanh(double x) (−1, 1)
*q
2
double erf(double x) erf(x) = √2π 0 e−t dt
double erfc(double x) erfc(x) = 1 − erf(x)
3x
Γ(x)
x · y + z
float
long double
double copysign(double x, double y)
double fmin(double x, double y)
double fmax(double x, double y)
double fdim(double x, double y)
double fabs(double x)
double abs(double x)
2 /2
x e−x
3! 5! 7!
89 261 1511
std::vector<>
std::vector<>
std::vector<>
std::vector<>
4
i a i bi a b
[a, b]
n
n xi , y i 1 ≤ x i ≤ 1 1 ≤ yi ≤ 1
x2 + y 2 = 1 2
n n = 103 n = 104
n= 109 n
2
2
http://tinyurl.com/114rndint
x = r cos θ , y = r sin θ .
4 x y r θ
π
N
N
4 $ 1
p(N ) = / 02 .
N k=1 k− 12
1+ N
limN →∞ p(N ) = π
π
N = 1, 2, 10, 50, 100, 500
N
π e(N ) = |p(N )−π|
Nmin e(Nmin ) < 10−6
K 1024 = 210
2
K = d9 29 + d8 28 + · · · d1 21 + d0 20 .
d9 d8 d1 d0
K
10
d0 d9
81 833 173
k
k +1 2
10000
ex
35◦
ex sin x
cos x
∞ n
$ ∞
$ ∞
$
x (−1)n x2n+1 (−1)n x2n
ex = , sin x = , cos x = .
n=0
n! n=0
(2n + 1)! n=0
(2n)!
10−10
http://bit.
ly/2f4Obpy 126
std::vector<>
200 http://tinyurl.com/q8cuydn
2 + 3i 5.7 − 9i
C F F =
9/5 C + 32
22 ◦C
0 −273.15 ◦C
6000 ◦C
100 ◦ F
ax2 +
bx + c = 0
a b c
http://tinyurl.com/114matrixA http://tinyurl.com/114matrixB
⎛ ⎞
2.3 − i 1 − 7i 5.8 −2.9 − 3.7i
⎜ −4.9i i 9 − 0.3i −2 + 0.72i ⎟
⎜ ⎟
⎜ ⎟
⎝ 8.2 + 4i −0.8 + i 0.2 + 5i 9 − 3i ⎠
2.3i −7.1 + 9i 0.9 −4i
t
x(t)
t x(t) 4
t = 0.0 0.5 1.0 100.0 s
2
(n − 1)! × n , n > 0 ,
n! =
1, n=0.
n
n
15
2
4096 65534 1855932
2
10
19791 4774
1000000
57960
2 6
0
http://tinyurl.com/ints201411 3590
2, 8, 8, 3, 5, 5, 5, 8, 8, 1, 6, 7, 7, 7
7
⃗r = (x, y, z) θ
x̂
⃗r
< <
<1 0 0 <
< <
< <
Rx (θ) = <0 cos θ − sin θ <,
< <
<0 sin θ cos θ <
⎛ ⎞ < <⎛ ⎞
x′ <1 0 0 < x
< <
⎜ ′ ⎟ < <⎜ ⎟
⎝ y ⎠ = <0 cos θ − sin θ <⎝ y ⎠ .
< <
z′ <0 sin θ cos θ < z
ŷ ẑ
< <
<cos θ 0 − sin θ <
< <
< <
Ry (θ) = < 0 1 0 <
< <
< sin θ 0 cos θ <
< <
<cos θ − sin θ 0 <
< <
< <
Rz (θ) = < sin θ cos θ 0 <.
< <
< 0 0 1 <
θ
x = 0.5 y = −0.3 z =
1.2 30◦
ŷ 35◦ x̂
58◦ ẑ
Hn (x) n 0 1
H0 (x) = 1
H1 (x) = 2x
H2 (x) = 4x2 − 2
=
n
x
Hn (x)
yn (x)
n 0, 1, . . .
y0 (x) = 1
y1 (x) = x + 1
y2 (x) = 3x2 + 3x + 1
=
m V = kx2 /2
. +√ ,1/4
1 km 2 /2
ψn (y) = n
√ Hn (y)e−y ,
2 n! π h̄
5√
y=x km/h̄
ψψ ∗
nx m = k = h̄ = 1
n = 5 60 x [−6, 6]
x x ψψ ∗
Pℓ (x) x ∈ [−1, 1] ℓ 0 1
P0 (x) = 1 P1 (x) = x
ℓ
ℓ
x
Pℓ (x)
http://tinyurl.com/114rndint
N
1000
x0 = 0.1 a mod 1 a
xi [0, 1)
A N ×N
N
$
det A = (−1)i+j aij det A=ij ,
i=1
j 1 A i j
aij A=ij A
i j
x
.
2ℓ + 1 (ℓ − m)! m
Yℓm (θ, φ) = P (cos θ)eimφ .
4π (ℓ + m)! ℓ
Pℓm (x)
ℓ=m
http://mathworld.wolfram.com/DeterminantExpansionbyMinors.html
http://mathworld.wolfram.com/CramersRule.html
ℓ=m+1
Pℓm (x) = x(2m + 1)Pm
m
(x) ,
Pℓm (x)
Yℓm (θ, φ)
50 × 100 θ−φ
Yℓm (θ, φ)
sin θ cos φ sin θ sin φ
∗ (θ, φ)
cos θ Yℓm (θ, φ)Yℓm x y z ψψ ∗
ℓ=2 m=0 d
f (x)
x̄ f (x) f (x̄) = 0
x0 x1 x2
f (x2 ) − f (x0 )
w0 =
x2 − x0
f (x2 ) − f (x1 )
w1 =
x2 − x1
w1 − w0
a = ,
x1 − x0
b = w0 + a(x2 − x0 ) ,
c = f (x2 ) .
2c
x3 = x2 − ,
d
d √ √
b+ b2 − 4ac b − b2 − 4ac
x0 ← x1 x1 ← x2 x2 ← x3
xn q A B C D
f (x) = x3 − x + 1
Γ(z)
> ?z
∞ n 1+ 1
1 % n
Γ(z) = .
z n=1 n + z
/ 0 / 0
1 5 3
Γ Γ = π.
2 2 4
1 10−12
n Jn (x)
∞
$ / 02m+n
(−1)m x
Jn (x) = .
m=0
m!(m + n)! 2
J0 (x) J1 (x)
J2 (x) 150 xi [0, 20]
10−12
a
x0
x0 = 1
x3i + 2a
xi+1 = xi
2x3i + a
x1 , x 2 , . . .
x30 + 2a
x1 = x0 ,
2x30 + a
x3 + 2a
x2 = x1 13 ,
2x1 + a
√
x1 , x 2 , . . . 3
a
xk
|x3k − a| ≤ ε ε 10−12
3×3 N ×N
N
M ×N 7 6
N N ×N N >3
N
N ×N
0
column[i]
0
1
1
N N
9×9
3×3 1−9
2 3
1 9
x=0 y=0
(x′ , y ′ )
x′ = a · x + b · y + e
y′ = c · x + d · y + f
abcdef
x′ → x y′ → y
(x′ , y ′ )
(x, y)
4
7 6
a, b, c, d, e, f p
4
pi 1
r [0, 1)
0 ≤ r < p1
p 1 ≤ r < p1 + p 2
1000
0 0 0 0.16 0 0 0.01
0.85 0.04 −0.04 0.85 0 1.6 0.85
0.2 −0.26 0.23 0.22 0 1.6 0.07
−0.15 0.28 0.26 0.24 0 0.44 0.07
0 0 0 0.25 0 −0.4 0.02
0.95 0.005 −0.005 0.93 −0.002 0.5 0.84
0.035 −0.2 0.16 0.04 −0.09 0.02 0.07
−0.04 0.2 0.16 0.04 0.083 0.12 0.07
10 × 10
p(z)
z0 p′ (z0 ) ̸= 0
p(z) p(z)
p(zi )
zi+1 = zi − , i = 0, 1, 2, . . . .
p′ (zi )
z0
z1 z2
p(z)
|p(zi )| ≤ ϵ ϵ
p(z) = z 3 − 1 a=
1 b = ei2π/3 c = e−i2π/3
z = 0 + i0
a (255, 0, 0)
b (0, 255, 0)
c (0, 0, 255) 0 + i0
(255, 255, 255)
N = 512
[−1, 1] xi i = 0, . . . , N − 1
M = 512
[−1, 1] yj j = 0, . . . , M − 1
z = xi + iyj
(i, j)
static_assert()
assert() errno
static_assert()
static_assert
int 32767
std::numeric_limits<int>::max()
int
1000000
static_assert(std::numeric_limits<int>::max() > 1000000,
"int␣is␣not␣sufficient");
<cassert>
assert()
assert
assert()
assert()
NDEBUG
<cassert> #define NDEBUG
assert()
0 false
assert(N<10);
(N<10)
std::
math_errhandling
MATH_ERRNO errno
MATH_ERREXCEPT
(MATH_ERRNO | MATH_ERREXCEPT)
math_errhandling MATH_ERRNO MATH_ERREXCEPT
<cmath>
errno
ERANGE FE_OVERFLOW
HUGE_VAL HUGE_VALF HUGE_VALL
double float long double
errno ERANGE
FE_DIVBYZERO ±INFINITY
INFINITY std::isinf() <cmath>
errno
ERANGE FE_UNDERFLOW
0.0 0
std::isnormal() <cmath>
0 errno
std::feclearexcept(FE_ALL_EXCEPT);
errno
std::fetestexcept() <cfenv>
true/false
#include <cerrno>
#include <cfenv>
#include <cmath>
#include <limits>
#include <iostream>
int main()
{
if (MATH_ERRNO != 1 && MATH_ERREXCEPT != 2) {
std::cerr << "not␣supported\n";
return -1;
}
std::sqrt(-1.0);
// errno becomes EDOM, FE_INVALID is raised
errno = 0;
std::feclearexcept(FE_ALL_EXCEPT);
std::pow(std::numeric_limits<double>::max(), 2);
// errno becomes ERANGE, FE_OVERFLOW is raised
if (errno == ERANGE || std::fetestexcept(FE_OVERFLOW)) {
std::cerr << "Math␣result␣not␣representable.\n";
}
errno = 0;
std::feclearexcept(FE_ALL_EXCEPT);
auto y = 1.0/0.0;
// errno becomes ERANGE, FE_DIVBYZERO is raised
std::strerror() <cstring>
errno char *
#include <cerrno>
#include <cmath>
#include <cstring>
#include <iostream>
int main()
{
errno = 0; // clear error
std::cerr << std::strerror(errno) << '\n';
≡int ≡double
std::get<0>(p) = 5; // p = (5,2.0)
std::get()
std::tuple<T1,T2,T3,...> std::pair<>
<tuple>
n n = 0, 1, . . .
≡int ≡double ≡int
std::pair<>
std::tuple<> std::pair<>
<algorithm>
std::min() std::max()
std::minmax()
< std::minmax()
std::pair<>
<
auto a = std::min(3.1,5.5); // a = 3.1
auto b = std::max({12,3,5,17,9});// b = 3
auto c = std::minmax({3,2,9,-1});// c.first = -1, c.second = 9
std::min()
<utility>
std::swap()
double a{3.1};
double b{4.2};
std::swap(a,b); // a = 4.2, b = 3.1
std::swap<>
std::complex<>
std::swap()
int a[100];
int b[100];
...
a[15] = 9;
b[15] = 4;
...
std::swap(a,b); // a[15] = 4, b[15] = 9
()
<functional>
std
std::plus<T>
std::plus<int> a;
auto b = a(3,5);
int 8
std::plus<int>{}
std::plus<int>
double() double{} 0.0
()
operator()
()
negate<T>{} −
plus<T>{} +
minus<T>{} −
multiplies<T>{} ∗
divides<T>{} /
modulus<T>{} %
equal_to<T>{} ==
not_equal_to<T>{} !=
less<T>{} <
greater<T>{} >
less_equal<T>{} <=
greater_equal<T>{} >=
logical_not<T>{} !
logical_and<T>{} &&
logical_or<T>{} ||
bit_and<T>{} &
bit_or<T>{} |
bit_xor<T>{} ^
[]
[&a,b]
&
=
mutable
noexcept
->type
return
auto x = fun(-5,3); // x = 3
auto
5 5.4 5.8
std <functional>
std::bind()
std::bind()
std::minus<int> a;
std::bind()
std::placeholders
()
10
10
()
()
std::bind()
std::placeholders::_1
std::placeholders::_2 std::placeholders::_3
using cntr = std::array<int,10>;
cntr a, b;
auto && sizea = std::bind(&cntr::size, a);
std::cout << "the␣size␣of␣a␣is␣" << sizea() << '\n';
auto && size = std::bind(&cntr::size, std::placeholders::_1);
std::cout << "the␣size␣of␣b␣is␣" << size(b) << '\n';
std::mem_fn()
std::mem_fn()
std::bind()
std::mem_fn()
std::array<int,10> a;
auto && size = std::mem_fn(&std::array<int,10>::size);
std::cout << "the␣size␣of␣a␣is␣" << size(a) << '\n';
&
true/false
comp()
comp(a,a)==false
comp(a,b)==true comp(b,c)==true
comp(a,c)==true
comp(a,b)==false comp(b,a)==false
true false
std::bind()
true false
true false
[−2.5, 4.5)
std::mem_fn()
imag() std::complex<>
std::string
&
std::vector<double>
std::vector<double>::iterator it;
c.begin()
c.end()
std::vector<double>
std::vector<double>::iterator b{v.begin()};
std::vector<double>::iterator e{v.end()};
auto
auto b = v.begin();
auto e = v.end();
<iterator>
std::vector<double>
std::vector<double>::const_iterator it;
cbegin() cend()
begin() end()
iterator const_iterator
const_iterator
std::vector<int> v(100);
std::vector<int>::const_iterator it1{v.begin()};//correct
std::vector<int>::iterator it2{v.cbegin()}; // error
const
std::vector<double> v(100);
auto const it1 = v.begin();
auto const it2 = v.cbegin();
std::vector<int>
typename
typename std::vector<T>::iterator itv; // correct
typename C::iterator itb; // correct
*
*it
* end()
->
(*it).member
it->member
*
.
++ --
begin() end()
+= -=
== !=
range for
for (auto & x : v) {
x = 3.5;
}
range for
std::vector<double>
for (auto it = v.cbegin(); it != v.cend(); ++it) {
std::cout << *it << '\n';
}
const_iterator std::vector<double>
*it
->
++it it++
auto q = p;
++p;
++q;
bool eq{p==q};
true
istream_iterators
*it = ...
*it
++it it++
ostream_iterators
* ->
std::forward_list<>
std::unordered_set<>
std::unordered_multiset<>
std::unordered_map<>
std::unordered_multimap<>
--
std::list<>
std::set<>
std::multiset<>
std::map<>
std::multimap<>
+= -=
it[n] *(it+n)
std::array<>
std::vector<>
std::deque<>
std::string
T const *
<iterator>
advance()
it += n;
++it
next()
template<typename ForwardIterator>
ForwardIterator next(ForwardIterator it, Dist n = 1);
std::advance()
prev()
template<typename BidirectionalIterator>
BidirectionalIterator prev(BidirectionalIterator it, Dist n = 1);
typename std::iterator_traits<ForwardIterator>::difference_type
std::advance()
distance()
template<typename InputIterator>
Dist distance(InputIterator it1, InputIterator it2);
it2-it1
iterator_traits<>
iterator_traits<>
typename std::iterator_traits<T>::iterator_category
std::output_iterator_tag
std::input_iterator_tag
std::forward_iterator_tag
std::bidirectional_iterator_tag
std::random_access_iterator_tag
typename
std::iterator_traits<BidirectionalIterator>::difference_type
typename std::iterator_traits<InputIterator>::difference_type
typename std::iterator_traits<T>::value_type
typename std::iterator_traits<T>::difference_type
+=
<
#include <iterator>
std::advance()
beg1 != end1
beg1 == std::prev(end1)
std::next(beg1) == end1
std::prev()
std::next()
std::random_access_iterator_tag
std::forward_iterator_tag
std::input_iterator_tag
#include <iterator>
template<typename Iterator1, typename Iterator2>
void copyodd(Iterator1 beg1, Iterator1 end1, Iterator2 beg2,
std::random_access_iterator_tag name)
{
while (beg1 < end1) {
*beg2 = *beg1;
if (beg1 == end1 - 1) {
break;
}
beg1+=2;
++beg2;
}
}
copyodd()
a[0] a+5
a[4]
a+5
std::begin() std::end()
<iterator>
std::vector<double>
std::vector<double>::reverse_iterator
std::vector<double>::const_reverse_iterator
rbegin() rend()
reverse_iterator
crbegin() crend()
const_reverse_iterator
++ --
std::vector<double>
std::cin
std::istream_iterator<int> a{std::cin};
std::cin
++ *
std::istream_iterator<int> b{};
std::ifstream in{"data"};
std::istream_iterator<double> beg{in}, end{};
double s{0.0};
for (auto it = beg; it != end; ++it) {
s += *it;
}
std::cout
*beg
++
std::istream_iterator<> std::ostream_iterator<>
<iterator>
*a
<iterator> std::insert_iterator<>
std::insert_iterator<std::vector<int>> iend{v,v.end()};
*iend = 1; // v is {1}
++iend;
*iend = 2; // v is {1, 2}
++iend;
*iend = 3; // v is {1, 2, 3}
++iend;
std::insert_iterator<std::vector<int>> ibeg{v,v.begin()};
*ibeg = -1; // v is {-1, 1, 2, 3}
++ibeg;
*ibeg = -2; // v is {-1, -2, 1, 2, 3}
++ibeg;
v.begin()
reserve()
std::inserter() <iterator>
std::vector<int> v;
auto it = std::inserter(v,v.begin());
std::vector<int> c;
it = std::inserter(c, c.end());
std::insert_iterator<> std::inserter()
insert() insert()
std::array<> std::forward_list<>
<iterator>
std::back_insert_iterator<>
std::vector<int> v;
std::back_insert_iterator<std::vector<int>> b{v};
push_back()
std::vector<> std::deque<>
std::list<>
std::back_inserter()
std::vector<int> v;
auto it = std::back_inserter(v);
std::front_insert_iterator<>
std::list<int> c;
std::front_insert_iterator<std::list<int>> b{c};
push_front()
std::deque<> std::list<>
std::forward_list<>
std::front_inserter()
std::list<int> c;
auto it = std::front_inserter(c);
std::move_iterator <iterator>
#include <vector>
#include <iterator>
#include <iostream>
int main()
{
using cntr = std::vector<std::vector<int>>;
cntr a(5, {1,2,3});
cntr b(5);
std::cout << "␣sizes␣of␣a␣before:␣";
for (auto const & x: a) {
std::cout << x.size() << '␣';
}
std::cout << "\b\n";
std::cout << "␣sizes␣of␣b␣before:␣";
for (auto const & x: b) {
std::cout << x.size() << '␣';
}
std::cout << "\b\n";
std::move_iterator<cntr::iterator> beg{a.begin()};
std::move_iterator<cntr::iterator> end{a.end()};
auto bit = b.begin();
for (auto ait = beg; ait != end; ++ait) {
*bit = *ait;
++bit;
}
std::cout << "␣sizes␣of␣a␣after:␣";
for (auto const & x: a) {
std::cout << x.size() << '␣';
}
std::cout << "\b\n";
std::cout << "␣sizes␣of␣b␣after:␣";
for (auto const & x: b) {
std::cout << x.size() << '␣';
}
std::cout << "\b\n";
}
5
std::make_move_iterator()
<iterator>
move_iterator
true false
template<typename Iterator1, typename Iterator2>
Iterator2
uniq(Iterator1 beg1, Iterator1 end1, Iterator2 beg2)
{
}
std::vector<int>
1, 6, 6, 5, 2, 2, 2, 8, 9, 9, 8, 9, 7, 0, 1, 1
1, 6, 5, 2, 8, 9, 8, 9, 7, 0, 1
{2, 2, 3, 4, 4, 2, 5, 6, 7} {9, 8, 7, 6, 4, 2, 5, 4, 3, 2, 1, 2, 4}
6 {2, 3, 4, 5, 6, 7}
array<> vector<> deque<> forward_list<> list<>
std::string
unordered_set<>
unordered_multiset<>
unordered_map<>
unordered_multimap<>
std::map<> std::multimap<>
std::unordered_map<> std::unordered_multimap<>
std::array<>
constexpr
std::array<>
<array> array<>
<vector> vector<>
<deque> deque<>
<forward_list> forward_list<>
<list> list<>
std
std::array<>
<T>
cntr<T> c1;
cntr<T> c1;
// fill c1 ....
cntr<T> c2{c1};
cntr<T> c2=c1;
cntr<T> c2(c1);
cntr<T> c1;
// fill c1 ....
cntr<T> c2{std::move(c1)};
cntr<T>
cntr<T> c2=std::move(c1);
cntr<T> c2(std::move(c1));
T v1, v2, v3, ...;
cntr<T> c1{v1, v2, v3, ... };
cntr<T> c1{beg,end};
double
int int double
std::complex<double>
#include <vector>
#include <set>
std::vector<int> v1{0,2,-2,4,-4,6,-6};
std::vector<int> v2{v1};
std::set<int> s1{v1.cbegin(), v1.cend()};
std::set<int> s2{std::move(s1)};
std::array<>
cntr<T> c1,c2;
...
c1 = c2;
c1 = std::move(c2);
std::move() <utility>
cntr<T> c;
c = {v1,v2,v3, ...};
std::swap() <utility>
cntr<T> c1,c2;
std::swap(c1,c2);
swap()
cntr<T> c1,c2;
c1.swap(c2);
swap()
insert() array<>
forward_list<>
insert_after()
cntr<T> c;
c.insert(pos, elem);
std::move()
insert()
clear()
void
c.clear();
erase()
array<> forward_list<>
c.erase(pos);
c.erase(beg,end);
std::string
const_iterator iterator
const_reverse_iterator reverse_iterator
typedef
value_type
reference
const_reference
pointer
const_pointer
difference_type
size_type
std::vector<double> std::vector<double>::value_type
std::vector<double>::value_type a{v[0]};
double
template<typename C>
void f(C c)
{
typename C::value_type a;
...
}
a.member();
forward_list<>
forward_list<> before_begin()
cbefore_begin()
*
rbegin() rend()
crbegin() crend()
begin()
end()
cbegin()
cend()
rbegin()
rend()
crbegin()
crend()
forward_list<>
array size()
false/true
size()==0
std::vector<double>::size_type n{v.size()};
auto
auto n = v.size();
std::array<>
std::array<>
<array>
array
constexpr
std::array<T,N> a;
std::array<T,N> a1;
// assign values to a1 ...
std::array<T,N> a2{a1};
std::array<T,N> a2 = {a1};
std::array<T,N> a2 = a1;
std::array<T,N> a2(a1);
std::move()
std::array<T,N> a1;
// assign values to a1 ...
std::array<T,N> a2{std::move(a1)};
T v1,v2,..., vN;
std::array<T,N> a{v1, v2, ..., vN};
T{}
0
std::array<int,10> a;
std::array<int,10> b{};
10
0
fill()
std::array<int,10> a;
a.fill(20);
10
20
std::array<int,10> a, b;
a.fill(20);
b = a;
b = std::move(a);
std::array<int,3> a;
a = {-1,-2,-3};
std::swap() <utility>
std::array<int,10> a, b;
a.fill(20);
std::swap(a,b);
swap()
b.swap(a);
swap()
[]
std::array<int,5> a{2,4,6,8,10};
std::cout << a[0] << '\n'; // a[0] = 2
a[3] = a[2]+a[1]; // a[3] = 10
at()
std::array<> a.at[0]
a.at[1] a.at[2]
std::out_of_range
std::array<int,5> a{2,4,6,8,10};
std::cout << a.at(0) << '\n';
std::cout << a.at(10) << '\n';
std::get()
std::array<int,5> a{2,4,6,8,10};
std::cout << std::get<3>(a) << '\n'; // a[3] = 8
std::get<0>(a) = 5; // a[0] = 5
std::get()
front() back()
std::array<int,5> a{2,4,6,8,10};
std::cout << "first␣element␣is␣" << a.front()
<< "␣last␣element␣is␣" << a.back() << '\n';
a.front() = 11; // a[0] = 11
a.back() = 55; // a[4] = 55
*
const_iterator
std::array<int,5> a{2,4,6,8,10};
int * p{&a[1]};
*p=30;
--p; // p ≡ &a[0]
*p=1;
30 1
data()
std::array<int,5> a{2,4,6,8,10};
int * p{a.data()}; // p ≡ &a[0]
p+=2; // p ≡ &a[2]
*p=-1;
−1
std::vector<>
✲
std::vector<>
std::vector<>
<vector>
std::vector<>
std::vector<T> v;
std::vector<T> v1;
std::vector<T> v2{v1};
std::vector<T> v3{std::move(v1)};
std::vector<T> v{beg,end};
std::vector<T> v(N);
T{}
0
size_type
reserve()
size_type
std::vector<T> v;
v.reserve(N);
push_back()
std::vector<T> v(N);
v[0] v[1] v[N-1]
reserve()
shrink_to_fit()
capacity()
size()
std::vector<T> v1, v2, v3;
...
v2 = v1;
v3 = std::move(v1);
std::vector<T> v;
T a1, a2, a3, ...;
v = {a1,a2,a3, ...};
swap() std::swap()
std::vector<T> v1, v2, v3;
...
v1.swap(v2);
std::swap(v3,v1);
insert()
v.insert(pos, elem);
insert()
v.insert(pos, N, elem);
v.insert(pos, beg, end);
v.insert(pos, {a1, a2, a3, ...});
0 N==0 beg==end
insert()
v.push_back(elem);
v.push_back(elem);
v.insert(v.cend(),elem);
emplace()
std::vector<std::complex<double>> v;
v.emplace(v.cend(), 3.1, 2.1);
3.1 + i2.1
emplace_back()
v.emplace_back(a,b,c,...);
v.emplace(v.cend(), a,b,c,...);
assign()
v.assign(N,elem);
v.assign(beg, end);
v.assign({a1,a2,a3,...});
resize()
v.resize(N);
v.resize(N,elem);
reserve()
v.insert(v.cend(),1); // v is {1}
v.insert(v.cend(),2); // v is {1,2}
clear()
v.clear();
erase()
v.erase(pos);
v.erase(beg,end);
resize()
push_back() pop_back()
v.pop_back();
v.erase(v.cend()-1);
vector<> array<>
std::get()
[]
at()
std::vector<> v.at[0]
v.at[1] v.at[2]
[0:v.size())
std::out_of_range
front() back()
*
const_iterator
data()
std::vector<>
#include <iostream>
#include <vector>
#include <cstddef>
int main()
{
std::vector<double> v(9);
// v = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
auto v2 = v; // v2 is a copy of v
// print v2
std::cout << "v2␣is\t";
for (auto const & x : v2) {
std::cout << x << '␣';
}
std::cout << '\n';
}
std::vector<bool>
bool std::deque<bool>
bool
std::deque<>
std::deque<>
std::vector<>
✛ ✲
std::deque<>
capacity() reserve()
deque
data()
std::deque<>
<deque>
3
#include <deque>
#include <iostream>
int main()
{
std::deque<int> d{0}; //deque with one element, 0.
//fill with values:
for (int i{1}; i < 100; ++i) {
d.push_back(i);
d.push_front(-i);
}
// d is {-99,-98, ..., -1, 0, 1, ..., 98, 99}
// print d:
for (auto it = d.cbegin(); it != d.cend(); ++it) {
std::cout << *it << '␣';
}
std::cout << '\n';
}
std::list<>
list<>
vector<> deque<>
✲ ✲ ✲ ✲ ✲ ✲ ✲ ✲
✛ ✲
✛ ✛ ✛ ✛ ✛ ✛ ✛ ✛
list<>
✲
✛
✻ ✻
❄ ❄
✲ ✲ ✲ ✲ ✲ ✲ ✲
✛ ✲
✛ ✛ ✛ ✛ ✛ ✛ ✛
std::list<>
<list>
std::list<>
vector<> deque<>
std::list<T> c;
std::list<T> c1;
std::list<T> c2{c1};
std::list<T> c3{std::move(c1)};
std::list<T> c{beg,end};
std::list<T> c(N);
list<>
deque<>
std::list<T> c1, c2, c3;
...
c2 = c1;
c3 = std::move(c1);
std::list<T> c;
T a1, a2, a3, ...;
c = {a1,a2,a3, ...};
swap() std::swap()
std::list<T> c1, c2, c3;
...
c1.swap(c2);
std::swap(c3,c1);
insert()
c.insert(pos, elem);
c.insert(pos, N, elem);
c.insert(pos, beg, end);
c.insert(pos, {a1, a2, a3, ...});
insert()
0 N==0 beg==end
assign()
c.assign(N,elem);
c.assign(beg, end);
c.assign({a1,a2,a3,...});
c.push_front(elem);
c.push_back(elem);
emplace()
emplace_front() emplace_back()
resize()
v.resize(N);
v.resize(N,elem);
splice()
std::list<T> c1, c2;
std::list<T>::const_iterator pos; // iterator to c1
...
c1.splice(pos, c2);
merge()
comp()
comp()
true false
clear()
c.clear();
erase()
c.erase(pos);
c.erase(beg,end);
resize()
pop_front() pop_back()
remove()
c.remove(a);
c.remove_if(op);
remove_if()
op() op()
true false remove_if() op()
op()
true
remove() erase()
erase()
remove()
unique()
c.unique();
c.unique(comp);
comp() comp()
unique() comp()
comp() true
front() back()
*
reverse()
sort() N
N log N
c.sort();
c.sort(comp);
<
comp()
comp()
true false
comp()
#include <list>
#include <iostream>
bool lessthan10(double a)
{
return a < 10.0;
}
int main()
{
std::list<double> c; // creates empty list
c.remove(16.0);
// any element with value equal to 16.0 is erased.
c.remove_if(lessthan10);
// all elements with value less than 10 are erased.
c.remove_if(lessthan10);
c.remove_if(std::bind(std::less<double>{},
std:placeholders::_1,10.0));
<functional>
lessthan10()
std::forward_list<>
✲ ✲ ✲ ✲ ✲ ✲ ✲ ✲
forward_list<>
before_begin() cbefore_begin()
list<>
_after
before_begin() cbefore_begin()
forward_list<>
end()
size()
std::forward_list<>
<forward_list>
std::forward_list<> std::list<>
std::forward_list<>
std::forward_list<T> c;
std::forward_list<T> c1;
std::forward_list<T> c2{c1};
std::forward_list<T> c3{std::move(c1)};
std::forward_list<T> c{beg,end};
std::forward_list<T> c(N);
#include <iterator>
#include <forward_list>
std::forward_list<T> c;
...
auto size = std::distance(c.cbegin(), c.cend());
forward_list<>
std::forward_list<T> c;
T a1, a2, a3, ...;
c = {a1,a2,a3, ...};
swap() std::swap()
std::forward_list<T> c1, c2, c3;
...
c1.swap(c2);
std::swap(c3,c1);
insert_after()
c.insert_after(pos, elem);
c.insert_after(pos, N, elem);
c.insert_after(pos, beg, end);
c.insert_after(pos, {a1, a2, a3, ...});
insert_after()
0 N==0
beg==end
assign()
c.assign(N,elem);
c.assign(beg, end);
c.assign({a1,a2,a3,...});
c.push_front(elem);
emplace_after()
emplace_front()
resize()
v.resize(N);
v.resize(N,elem);
splice_after()
merge()
comp()
clear()
erase_after()
c.erase_after(pos);
c.erase_after(beg,end);
resize()
pop_front()
remove()
c.remove(a);
c.remove_if(op);
remove_if()
op() true
unique()
c.unique();
c.unique(comp);
unique() comp()
comp() true
front()
*
reverse()
sort() N
N log N
c.sort();
c.sort(comp);
<
comp()
O(log N )
O(N )
std::set<>
std::multiset<> std::map<> std::multimap<>
std::set<> std::multiset<>
std::set<> std::multiset<>
<set>
std::set<T> std::multiset<T>
Set c;
Set c1;
Set c2{c1};
Set c3{std::move(c1)};
std::less<T>
<functional> <
true/false
std::set<T, std::greater<T>> c;
key_comp()
std::set<> std::multiset<>
size() empty() max_size()
swap() std::swap()
Set c1, c2, c3;
...
c1.swap(c2);
std::swap(c3,c1);
insert()
Set c;
T elem;
...
c.insert(elem);
insert()
Set c;
T elem;
Set::const_iterator pos;
...
c.insert(pos,elem);
c.insert(beg, end);
c.insert({a1, a2, a3, ...});
emplace()
std::set<std::string> c;
c.emplace("one"); // c is { "one" }
c.emplace("two"); // c is { "one", "two" }
c.emplace("three"); // c is { "one", "three", "two" }
emplace_hint()
clear()
c.clear();
erase()
Set c;
Set::value_type elem;
Set::const_iterator pos,beg,end;
c.erase(elem);
c.erase(pos);
c.erase(beg,end);
1
size_type
set<> multiset<>
O(log N ) O(N )
count()
size_type
find()
end()
cend()
lower_bound()
upper_bound()
equal_range()
#include <set>
#include <iostream>
#include <functional>
#include <iterator>
int main()
{
using crit = std::greater<int>;
std::cout << "Set:\n";
std::set<int,crit> c; // define empty set
// print set
std::cout << "Number␣of␣elements:␣" << c.size() << '\n';
for (auto it = c.cbegin(); it != c.cend(); ++it) {
std::cout << *it << '␣';
}
std::cout << '\n';
m = c.erase(6);
std::cout << "There␣were␣" << m << "␣elements␣with␣value␣6\n";
std::cout << '\n';
auto p = mc.equal_range(12);
std::cout <<"First␣12␣is␣in␣position␣"
<< std::distance(mc.cbegin(), p.first) << '\n';
std::cout <<"Last␣12␣is␣in␣position␣"
<< std::distance(mc.cbegin(), p.second)-1 << '\n';
// print multiset
std::cout << "Number␣of␣elements:␣" << mc.size() << '\n';
std::map<> std::multimap<>
std::map<> std::multimap<>
<map>
map<> set<>
multimap<>
multiset<>
std::map<>
std::multimap<>
std::map<K,T> std::multimap<K,T>
Map c;
Map c1;
Map c2{c1};
Map c3{std::move(c1)};
std::pair<K,T> p1{k1,a1};
std::pair<K,T> p2{k2,a2};
std::pair<K,T> p3{k3,a3};
...
Map c{beg,end};
std::less<K> <functional>
<
true/false
key_comp()
std::map<> std::multimap<>
size() empty() max_size()
Map c;
std::pair<K,T> p1{k1,a1};
std::pair<K,T> p2{k2,a2};
std::pair<K,T> p3{k3,a3};
...
c = { p1, p2, p3, ... };
swap() std::swap()
Map c1, c2, c3;
...
c1.swap(c2);
std::swap(c3,c1);
c.insert(elem);
std::pair<K,T>
Map c;
std::pair<K,T> elem;
Map:const_iterator pos;
c.insert(pos,elem);
c.insert(beg, end);
c.insert({p1, p2, p3, ...});
emplace()
emplace_hint()
clear()
c.clear();
erase()
Map c;
K key;
Map::const_iterator pos,beg,end;
c.erase(key);
c.erase(pos);
c.erase(beg,end);
size_type
(*it).first it->first
(*it).second it->second
std::map<>
std::set<>
[] at()
at()
c[key]
c.at(key)
c[key] = value;
std::make_pair(key,value)
c.at(key) std::out_of_range
map multimap
std::set<> std::multiset<>
count(key)
size_type
find(key)
end()
lower_bound(key)
upper_bound(key)
equal_range(key)
std::map<>
#include <iostream>
#include <string>
#include <map>
#include <utility>
int main()
{
using Map = std::map<std::string, int>;
std::unordered_set<>
std::unordered_multiset<>
std::unordered_map<>
std::unordered_multimap<>
std::unordered_multiset<> std::unordered_multimap<>
std::unordered_set<>
std::unordered_map<>
std::hash<> <functional>
true
false
std::equal_to<T> std::equal_to<K>
==
typedef
std::unordered_set<> std::unordered_multiset<>
<unordered_set> <unordered_map>
std::unordered_map<> std::unordered_multimap<>
std::unordered_set<T>
std::unordered_multiset<T>
std::unordered_map<K,T>
std::unordered_multimap<K,T>
Unord c;
Unord c1;
Unord c2{c1};
Unord c3{std::move(c1)};
Unord c{beg,end};
size() empty()
max_size()
swap() std::swap()
Unord c1, c2, c3;
...
c1.swap(c2);
std::swap(c3,c1);
Unord::value_type elem;
...
c.insert(elem);
Unord::value_type elem;
Unord:const_iterator pos;
c.insert(pos,elem);
c.insert(beg, end);
c.insert({p1, p2, p3, ...});
emplace()
emplace_hint()
clear()
c.clear();
erase()
Unord::const_iterator pos,beg,end;
c.erase(pos);
c.erase(beg,end);
erase()
c.erase(elem);
c.erase(key);
size_type
at() []
count()
size_type
find()
end()
cend()
equal_range()
hash_function() key_eq()
bucket_count()
max_bucket_count()
bucket_size()
bucket()
load_factor()
max_load_factor()
rehash()
reserve()
list unique() splice() merge() reverse()
std::list<T>
template<typename container>
void
split(container const & c, container & odd, container & even)
{
...
}
std::list<int> 3 5 −1 9 −7 88 3 −6 −4
split()
1958723584 60945983
<algorithm>
<numeric>
std
true/false
<numeric>
accumulate()
value += a1;
value += a2;
...
op()
value = op(value,a1);
value = op(value,a2);
...
beg==end
inner_product()
+
*
value += a1*b1;
value += a2*b2;
...
value = op1(value,op2(a1,b1));
value = op1(value,op2(a2,b2));
...
beg1==end1
partial_sum()
op()
beg2+i+1 op(*(beg2+i), *(beg1+i+1))
adjacent_difference()
< comp()
true false
comp()
min_element()
template<typename ForwardIterator>
ForwardIterator
min_element(ForwardIterator beg, ForwardIterator end);
beg==end
*it
max_element()
template<typename ForwardIterator>
ForwardIterator
max_element(ForwardIterator beg, ForwardIterator end);
beg==end
minmax_element()
template<typename ForwardIterator>
std::pair<ForwardIterator,ForwardIterator>
minmax_element(ForwardIterator beg, ForwardIterator end);
beg==end
p.first
p.second
copy()
op()
op() true
std::copy()
std::move()
move()
template<typename BidirectionalIterator1,
typename BidirectionalIterator2>
BidirectionalIterator2
copy_backward(BidirectionalIterator1 beg1,
BidirectionalIterator1 end1,
BidirectionalIterator2 end2);
end1-i end2-i i = 1, 2, . . .
std::move_backward()
move_backward()
template<typename BidirectionalIterator1,
typename BidirectionalIterator2>
BidirectionalIterator2
move_backward(BidirectionalIterator1 beg1,
BidirectionalIterator1 end1,
BidirectionalIterator2 end2);
end1-i end2-i i = 1, 2, . . .
rotate()
template<typename ForwardIterator>
ForwardIterator
rotate(ForwardIterator beg, ForwardIterator mid,
ForwardIterator end);
rotate_copy()
replace()
==
op() true
std::less<>
0
std::bind()
replace_copy()
op() true
1 1
remove()
==
op()
op() true
erase()
std::list<> std::forward_list<>
remove() std::remove()
std::greater_equal<>
0 std::bind()
remove_copy()
op() true
unique()
template<typename ForwardIterator>
ForwardIterator
unique(ForwardIterator beg, ForwardIterator end);
==
comp() comp() true false
std::list<> std::forward_list<>
unique() std::unique()
unique_copy()
template<typename InputIterator, typename OutputIterator>
OutputIterator
unique_copy(InputIterator beg1, InputIterator end1,
OutputIterator beg2);
std::unique()
==
comp()
reverse()
template<typename BidirectionalIterator>
void
reverse(BidirectionalIterator beg, BidirectionalIterator end);
std::list<> std::forward_list<>
reverse_copy()
template<typename BidirectionalIterator>
OutputIterator
reverse_copy(BidirectionalIterator beg1, BidirectionalIterator end1,
OutputIterator beg2);
random_shuffle()
template<typename RandomIterator>
void
random_shuffle(RandomIterator beg, RandomIterator end);
rng()
rng()
std::shuffle()
shuffle()
<random>
op() op()
true false
typename std::iterator_traits<RandomIterator>::difference_type
partition()
op() true
op() false
op() false
std::greater<>
0
std::bind()
stable_partition()
is_partitioned()
template<typename InputIterator, typename UnaryFunctor>
bool
is_partitioned(InputIterator beg, InputIterator end,
UnaryFunctor op);
op()
op() true false
true false
beg==end true
partition_point()
op()
std::partition(beg,end,op);
op() false
partition_copy()
op() true
op() false
std::pair<>
< comp()
true false
comp()
sort()
template<typename RandomIterator>
void
sort(RandomIterator beg, RandomIterator end);
n log n n
std::list<> std::forward_list<>
stable_sort()
template<typename RandomIterator>
void
stable_sort(RandomIterator beg, RandomIterator end);
nth_element()
template<typename RandomIterator>
void
nth_element(RandomIterator beg, RandomIterator nth,
RandomIterator end);
*nth
partial_sort()
template<typename RandomIterator>
void
partial_sort(RandomIterator beg, RandomIterator sortEnd,
RandomIterator end);
partial_sort_copy()
template<typename ForwardIterator>
bool
is_sorted(ForwardIterator beg, ForwardIterator end);
true
false
is_sorted_until()
template<typename ForwardIterator>
ForwardIterator
is_sorted_until(ForwardIterator beg, ForwardIterator end);
N N!
std::lexicographical_compare()
N!
p 1 p 2 . . . pn
k pk < pk+1
i>k pk < p i
pk pi
pk+1 pn
std::next_permutation()
lexicographical_compare()
true false
==
<
!(a<b) && !(b<a)
comp() !comp(a,b) && !comp(b,a)
next_permutation()
template<typename BidirectionalIterator>
bool
next_permutation(BidirectionalIterator beg,
BidirectionalIterator end);
false
true
<
comp()
true false
comp()
prev_permutation()
template<typename BidirectionalIterator>
bool
prev_permutation(BidirectionalIterator beg,
BidirectionalIterator end);
false
true
<
comp()
true false
comp()
is_permutation()
==
comp() comp() true false
<
comp()
comp()
true false
==
comp() comp()
true false
find()
==
op()
std::find_if()
op() true
std::find_if_not() op()
false
find()
find_first_of()
== comp()
search()
== comp()
beg2==end2
find_end()
std::search()
==
comp()
beg2==end2
adjacent_find()
template<typename ForwardIterator>
ForwardIterator
adjacent_find(ForwardIterator beg, ForwardIterator end);
binary_search()
< comp()
comp()
upper_bound()
< comp()
comp()
lower_bound()
< comp()
comp()
equal_range()
==
<
comp()
true false
comp()
==
!(a<b) && !(b<a)
!comp(a,b) && !comp(b,a)
merge()
std::list<> std::forward_list<>
inplace_merge()
template<typename BidirectionalIterator>
void
inplace_merge(BidirectionalIterator beg, BidirectionalIterator mid,
BidirectionalIterator end);
set_union()
1 2 1
2− 1
2> 1
set_intersection()
1
2 min{ 1 2}
set_difference()
1 2
max{ 1− 2 0}
set_symmetric_difference()
1
2 1− 2
1> 2 2− 1
2> 1 1= 2
includes()
<
comp()
true false
comp()
make_heap()
template<typename RandomIterator>
void
make_heap(RandomIterator beg, RandomIterator end);
is_heap()
template<typename RandomIterator>
bool
is_heap(RandomIterator beg, RandomIterator end);
true false
true
is_heap_until()
template<typename RandomIterator>
RandomIterator
is_heap_until(RandomIterator beg, RandomIterator end);
pop_heap()
template<typename RandomIterator>
void
pop_heap(RandomIterator beg, RandomIterator end);
−1 −1
push_heap()
template<typename RandomIterator>
void
push_heap(RandomIterator beg, RandomIterator end);
−1
−1
sort_heap()
template<typename RandomIterator>
void
sort_heap(RandomIterator beg, RandomIterator end);
all_of()
any_of()
op()
true true
false
count()
op() true
typename std::iterator_traits<InputIterator>::difference_type
auto cnt = std::count(v.cbegin(), v.cend(), a);
auto && lta = std::bind(std::less<decltype(a)>{},
std::placeholders::_1, a);
auto cnt2 = std::count_if(v.cbegin(), v.cend(), lta);
std::count_if()
auto && lta = [a] (decltype(a) x) -> bool {return x < a;};
equal()
false
==
comp()
mismatch()
std::pair<>
−
−
iota()
value+1 value+2
++
<numeric>
for_each()
op()
return std::move(op);
swap_ranges()
beg2+(end1-beg1)
transform()
op()
fill()
beg+n
generate()
op()
op()
op()
beg+n
1000000
[−1000000, 1000000]
−1234
0
10000
10000
100
std::equal()
template<typename Iterator>
bool equal(Iterator beg1, Iterator end1, Iterator beg2)
{
.....
}
std::list<>
1, 3, 5, 88, 92, 4, 91
1, 3, 5, 88, 92, 4, 2, 91
equal()
false
http://bit.ly/2bDuQxB http:
//bit.ly/2bIIhtv
std::string
class struct
;
class Student {
private:
std::string name;
std::string department;
int am;
int year;
bool active;
};
private:
#include <string>
class Student {
public:
std::string const & getName() const {return name;}
std::string const & getDept() const {return department;}
int const & getAm() const {return am;}
int const & getYear() const {return year;}
bool const & getActive() const {return active;}
private:
class public:
struct
class
setActive()
const
getName() getDept() getAm() getYear() getActive()
const
const
protected:
Student & s1{s};
Student const & s2{s};
s1.setActive(false); // correct
s2.setActive(false); // error
auto y1 = s1.getYear(); // correct
auto y2 = s2.getYear(); // correct
setYear()
getYear()
const
const
private
public
public
class Student {
public:
std::string const & getName() const;
std::string const & getDept() const;
int const & getAm() const;
int const & getYear() const;
bool const & getActive() const;
void Student::setActive(bool a)
{
active = a;
}
Student::
inline
inline
inline
template
#include "Student.h"
true
bool active{true};
std::string
std::string name{onoma};
std::string department{dept};
int am{armi};
int year{y};
bool active{act};
Student::Student(std::string const & onoma, std::string const & dept,
int armi, int y, bool act)
{
name = onoma;
department = dept;
am = armi;
year = y;
active = act;
}
std::string name;
name = onoma;
std::string department;
department = dept;
int am;
am = armi;
int year;
year = y;
bool active;
active = act;
std::string
const
:
Student(Student const & other);
Student p = std::move(s);
f(std::move(p));
Student q = f();
std::string
inline X(){}
X a; X a{};
X a();
X() = default;
X() = delete;
std::ifstream
~Student(){}
delete
inline ~X(){}
~X() = default;
~X() = delete;
= + < =
t=t;
operator=()
Student & operator=(Student const & other)
{
if (this != &other) {
name = other.name;
AM = other.AM;
Year = other.Year;
}
return *this;
}
this
operator=() if
a=b=c=d
⊗
operator⊗
⊗
.
sizeof
<
== operator<()
operator==()
<utility>
std::rel_ops
bool operator<(Student const & other)
{
return AM < other.AM;
}
template<typename T>
template<typename T>
class X {
T a;
...
};
X<double> x1;
X<int> x2;
x1.a x2.a
template<int N>
class Y {
std::array<double,N> v;
};
Y<10> c;
c.v 10
template<typename T>
<T>
template<typename T>
class X {
T a;
...
void f(T v);
};
template<typename T>
void X<T>::f(T v)
{
...
}
std::array<> <array>
#include <iostream>
#include "date.h"
if (a < b) {
std::cout << a << "␣is␣before␣" << b << '\n';
}
}
int main()
{
date a; // a = 1/1/1970
std::cout << a << '\n';
--a; // 31/12/1969
std::cout << a << '\n';
++f; // 22/8/2002
std::cout << f << '\n';
cmp(a,b);
cmp(d,e);
cmp(c,b);
d += 4; // d = 21/5/2005
std::cout << d << '\n';
e -= 3000; // e = 7/4/1997
std::cout << e << '\n';
f = d; // f = 21/5/2005
std::cout << f << '\n';
}
std::complex<>
template<typename T>
complex<T> {
}
#include <iostream>
#include "sudoku.h"
argv[1]
argv[2]
2001
#include <stdio.h>
int l;int main(int o,char **O,
int I){char c,*D=O[1];if(o>0){
for(l=0;D[l ];D[l
++]-=10){D [l++]-=120;D[l]-=
110;while (!main(0,O,l))D[l]
+= 20; putchar((D[l]+1032)
/20 ) ;}putchar(10);}else{
c=o+ (D[I]+82)%10-(I>l/2)*
(D[I-l+I]+72)/10-9;D[I]+=I<0?0
:!(o=main(c/10,O,I-1))*((c+999
)%10-(D[I]+92)%10);}return o;}
http://www.ioccc.org
1995
429539
#include <stdio.h>
l111 llll1 {
l111 llll1 *
lll1l,*ll1l1 ;l1l1 lll11 lll [
llll];};main (){l111 llll1 *ll11,*l1l,*
l1, *ll1l, * malloc ( ) ; l1l1 ll11l l1ll ;
ll11l l11,ll ,l;l1l1 lll11 *lll1,* lllll; ll1(l
=1-1 ;l< 14; ll1ll("\t\"8)>l\"9!.)>vl" [l]^'L'),++l
);scanf("%d",&l);l1l1l(l1l) l1l1l(ll11 ) (l1=l1l)->
lll[l1l->lll[1-1] =1]=l11l;ll1(l11 =1+1;l11<=l;
++l11){l1=ll11; lll1 = (ll1l=( ll11=l1l))->
lll; lllll =( l1l=l1)->lll; ll=(l1ll=1-1
);ll1(;ll1l-> lll1l||l11l!= *lll1;){l1ll
+=l11**lll1++ ;l1ll1 ll111 (++ll>llll){
l1lll lll1=( ll1l =ll1l-> lll1l)->lll;
}}ll1(;l1ll; ){l1ll1 ll111 (++ll>=llll)
{ l1lll} } * lllll=l11l;}
ll1(l=(ll=1- 1);(l<llll)&&
(l1->lll[ l] !=l11l);++l); ll1 (;l1;l1=
l1->ll1l1,l= llll){ll1(--l ;l>=1-1;--l,
++ll)printf( (ll)?((ll%19) ?"%04d":(ll=
19,"\n%04d") ):"%4d",l1-> lll[l] ) ; }
ll1ll(10); }
1996
#define x char
#define z else
#define w gets
#define r if
#define u int
#define s main
#define v putchar
#define y while
#define t "␣A?B?K?L?CIF?MSP?E?H?O?R?DJG?NTQ?????U?V?????X???????Z????W??Y??"
s ( ) { x* c , b[ 5 * 72 ]; u a, e , d [ 9
*9 *9 ] ; y (w ( b) ){ r ( 0 [ b] -7 *
5 ) { c = b ; y ( (* c - 6
* 7 )* * c )c = c+ 1 ; r (( -0 ) [ c ] && w ( b +
8 * 5* 3 ) && w (b +8 *5 * 6) )
{ a = 0; y ( a [ b ]
) { a [ d ] = ! ! ( a[ b] - 4 *8 ) ; a = a +
1; } y (a < 8 * 5 * 3 ) d [ ( a ++ )
] = 0 ; a = 0; y( b [
a + 8 *3 * 5 ] ) { d [ a ] = a [ d] + ! !( b[
a+ 40 * 3 ] -4 * 8) * 2 ; ++ a ; } a =
0 ; y ( a [ b + 6 * 40 ]
) {a [d ] += ! ! ( b[ a + 5 * 6 * 8 ] - 4 *
8 ) * 4; a = a + 1 ;} a= 0; y (a <3 *8
*5 ) { r ( a [ d ] ) { e
= 1 ; y ( e[ a + d] ){ * ( d+ a+ e ) = a[ d
+e - 1] +( d [ a + e ] << ( 3* e) ) ;e
= e + 1 ;} a = a +
e - 1 ; v( !! ( * ( d+
a) % ( 64 ) - 12 * 5
) + ( e
> 4 ) ?t [ e >2 ? 2 :a [ d ] ] :6 * 8 +( t [ d[
a ]/ 8 /8 ] -4 ) %( 10 ) ) ; r( ! (2 [a
+ d] + 3 [d + a ] ) ) v ( 4 * 8 )
; } a = a + 1 ; } v (5 * 2 ) ; } z {c =b ; e
= 0 ; y (* c ) { * c += - (* c > 8 * 12
) * 32 ; a = 8 * 8 ; r (* c
>= 48 &&* c<8 *8 -6) {*c =( * c + 1
) %( 5 * 2 ) + 65 ;y( --a >0 &&*
c- a[ t] ); d[ (e ++ )] =4 ;(
* ( d + (e ++) ))= 07 ;}z y(a -- >1
&&* c- t[a ]); d[ ( e = e + 1) -
1] =a %8 ;y (a /= 8) d[ (e ++
) ] = a% 8 ; ++ c ; * ( e ++ +d ) =0
;} -- e ;r ( e >0 ) {a = 1 ;
y ( a< 8 ) { c = b ;y
( c <e +b ) { v ( * ( c - b + d )& a? 6 *7
:8 * 4 ) ; c ++ ;} a= a + a ; v ( 2*
5) ; } v ( 5* 2 ) ; }} }} }
(1 +
N )/2 N
N
1 + log2 N
N
0
1
16 bit
[0, 65535] [0, 255]
256
h(k) = k mod 256
[0, 255]
N O(N 2 )
N
(2, 3) (3, 4) (N − 1, N )
(N − 2, N − 1) (N − 2, N − 1)
(1, 2)
N −1 N −2 1
O(N 2 )
O(N )
O(N 2 )
O(N log N ) N
N log N N
std::vector<int>
−1
std::vector<>
−1
std::vector<>
1254
http://tinyurl.com/114nonrepeat
std::vector<>
http://tinyurl.com/114rndint
std::vector<>
http://tinyurl.com/114nonrepeat
1254
316001 499160
main()
main() PROGRAM
extern "C"
int
f(double a)
{
.....
}
void
g(int a)
{
.....
}
extern "C"
int f(double a);
extern "C"
void g(int a);
extern "C" {
int f(double a);
void g(int a);
}
gcc -c fg.c
g++ prog.cpp fg.o
DLASRT()
CHARACTER ID
INTEGER INFO, N
DOUBLE PRECISION D( * )
ID (input) CHARACTER*1
= 'I': sort D in increasing order;
= 'D': sort D in decreasing order.
N (input) INTEGER
The length of the array D.
DLASRT() SUBROUTINE
void
void dlasrt(char id, int n, double d[], int info);
std::vector<>
const
void dlasrt(char const & id, int const & n, double d[], int & info);
extern "C"
extern "C"
void dlasrt_(char const & id, int const & n, double d[], int & info);
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3551.pdf
http://www.
cppstdlib.com
http://www.aristeia.com
&& ||
<cmath>
<cmath>
<cmath>
FE_OVERFLOW
|| FE_UNDERFLOW
INFINITY
& MATH_ERREXCEPT
&& MATH_ERRNO
*/ NAN
, NDEBUG
/* RAND_MAX
// and_eq
<< assert()
<algorithm> assign()
<array> at()
<cassert> before_begin()
<cerrno> break
<cfenv> capacity()
<cinttypes> case
<complex> cbefore_begin()
<cstddef> class
<cstdint>
<cstring> compl
<ctime> const
<ios> const_pointer
<iostream> const_reference
<iterator> constexpr
<limits> continue
<numeric> data()
<random> decltype()
<sstream> default
<string> difference_type
<vector> do while
CHAR_BIT else
FE_DIVBYZERO emplace()
FE_INVALID emplace_after()
emplace_back() std::atan()
emplace_front() std::atan2()
emplace_hint() std::atanh()
eof() std::back_insert_iterator<>
errno std::back_inserter()
std::begin()
std::bitset<>
extern std::boolalpha
false std::calloc()
fill() std::cbegin()
for std::cbrt()
get() std::ceil()
goto std::cend()
if std::cerr
inline std::cin
insert() std::clog
insert_after() std::conj()
key_comp() std::copysign()
main() std::cos()
math_errhandling std::cosh()
mutable std::cout
namespace std::default_random_engine
using std::defaultfloat
std::deque<>
std::distance()
noexcept std::div_t
nullptr std::end()
or_eq std::erf()
pointer std::erfc()
pop_back() std::exp()
precision() std::exp2()
push_back() std::expm1()
reference std::fabs()
reserve() std::fdim()
seekg() std::fetestexcept()
seekp() std::fixed
shrink_to_fit() std::floor()
size_type std::fma()
sizeof std::fmax()
static_assert() std::fmin()
static_cast<> std::fmod()
std::abs() std::forward_list<>
std::acos() std::free()
std::acosh() std::frexp()
std::advance() std::front_insert_iterator<>
std::arg()
std::array<> std::front_inserter()
std::asin() std::get()
std::asinh() std::hash<>
std::hypot() std::prev()
std::imaxdiv_t std::proj()
std::initializer_list<> std::ptrdiff_t
std::insert_iterator<> std::rand()
std::inserter() std::random_device
std::intmax_t std::real()
std::isinf() std::realloc()
std::isnan() std::remainder()
std::isnormal() std::remquo()
std::istream_iterator<> std::right
std::istringstream std::round()
std::iterator_traits<> std::scientific
std::ldexp() std::set<>
std::ldiv_t std::setfill()
std::left std::setprecision()
std::lgamma() std::setw()
std::list<> std::showpoint
std::lldiv_t std::showpos
std::log() std::sin()
std::log10() std::sinh()
std::log1p() std::size_t
std::log2() std::skipws
std::lround() std::sqrt()
std::make_move_iterator() std::srand()
std::make_pair() std::strerror()
std::make_tuple() std::string
std::malloc() std::swap()
std::map<> std::tan()
std::max() std::tanh()
std::min() std::tgamma()
std::minmax() std::time()
std::modf() std::trunc()
std::move() std::tuple<T1,T2,T3,...>
std::move_iterator std::u16string
std::multimap<> std::u32string
std::multiset<> std::uniform_int_distribution<int>
std::next()
std::noboolalpha std::uniform_real_distribution<double>
std::norm()
std::normal_distribution<double> std::vector<>
std::vector<bool>
std::noshowpoint std::wcerr
std::noshowpos std::wcin
std::noskipws std::wclog
std::ostream_iterator<> std::wcout
std::ostringstream std::wstring
std::pair<T1,T2> struct
std::polar() switch
std::pow() true
typedef std::logical_not<T>
typename std::logical_or<T>
using std::minus<T>
value_type std::modulus<T>
void std::multiplies<T>
while std::negate<T>
width() std::not_equal_to<T>
xor_eq std::plus<T>
long int
long long int
unsigned int
unsigned long int
unsigned long long int
std::bit_and<T>
std::bit_or<T>
std::bit_xor<T>
std::divides<T>
std::equal_to<T>
std::greater<T>
std::greater_equal<T>
std::less<T>
std::less_equal<T>
std::logical_and<T>
std::partial_sort_copy()
std::partial_sum()
std::partition()
std::partition_copy()
std::partition_point()
std::pop_heap()
std::accumulate() std::prev_permutation()
std::adjacent_difference() std::push_heap()
std::random_shuffle()
std::adjacent_find() std::remove()
std::all_of() std::remove_copy()
std::any_of() std::replace()
std::binary_search() std::replace_copy()
std::copy() std::reverse()
std::copy_backward() std::reverse_copy()
std::count() std::rotate()
std::equal() std::rotate_copy()
std::equal_range() std::search()
std::fill() std::search_n()
std::find() std::set_difference()
std::find_end() std::set_intersection()
std::find_first_of() std::set_symmetric_difference()
std::for_each()
std::generate() std::set_union()
std::includes() std::shuffle()
std::inner_product() std::sort()
std::inplace_merge() std::sort_heap()
std::iota() std::stable_partition()
std::is_heap() std::stable_sort()
std::is_heap_until() std::swap_ranges()
std::is_partitioned() std::transform()
std::is_permutation() std::unique()
std::is_sorted() std::unique_copy()
std::is_sorted_until() std::upper_bound()
std::lexicographical_compare()
std::lower_bound()
std::make_heap()
std::max_element()
std::merge()
std::min_element()
std::minmax_element()
std::mismatch()
std::move() struct
std::move_backward()
std::next_permutation()
std::none_of()
std::nth_element()
std::partial_sort()
|
|
<<
>>
&=
&
static_cast<> ~
^=
^
int
long int
long long int
short int
std::bind()
std::mem_fn()
constexpr imag()
real()
double
float
long double
char16_t
char32_t
char
wchar_t
namespace