Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Вывод элементов массива
//g++ 5.4.0 #include <iostream> #include <algorithm> #include <iterator> #include <functional> template <int I> struct outArray_helper { template <class T, int N, class F> static void print(const T(& arr)[N], const F& f) { outArray_helper<I-1>::print(arr, f); f(arr[I-1]); } }; template <> struct outArray_helper<0> { template <class T, int N, class F> static void print(const T(& arr)[N], const F& f) {} }; template <int N, class F> void outIntArray(const int(& arr)[N], const F& f) { outArray_helper<N>::print(arr, f); } int main() { int ary[] = { 0, 2, 4, 6, 8, 1, 3, 5, 7, 9 }; { using namespace std::placeholders; std::for_each(std::begin(ary), std::end(ary), std::bind(printf, "%d ", _1)); std::cout << '\n'; } { outIntArray(ary, [](auto x) { printf("%d ", x); }); std::cout << '\n'; } }
run
|
edit
|
history
|
help
0
mergesort tree
hilbert
Test 1(2021)
Test 20(2020)
CodeForces Div 3 - D
project
New wall
typedef
Cours C++
Bin Tree build