코딩/C++
std::array
by sonysame
2024. 3. 11.
#include <iostream>
#include <array>
#include <algorithm>
using namespace std;
void printLength(const array<int, 5> &my_arr)
{
cout << &my_arr << endl;
}
int main() {
array<int, 5> my_arr = { 1,3,2,4,5 };
cout << my_arr[0] << endl;
cout << my_arr.at(0) << endl;
cout << my_arr.size() << endl;
cout << &my_arr << endl;
printLength(my_arr);
for (auto &element : my_arr)
cout << element << " ";
cout << endl;
std::sort(my_arr.begin(), my_arr.end());
// std::sort(my_arr.rbegin(), my_arr.rend());
for (auto& element : my_arr)
cout << element << " ";
cout << endl;
}