Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Вывод элементов массива
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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'; } }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 1.23 sec, absolute running time: 0.11 sec, cpu time: 0.04 sec, memory peak: 3 Mb, absolute service time: 1,35 sec
edit mode
|
history
|
discussion
0 2 4 6 8 1 3 5 7 9 0 2 4 6 8 1 3 5 7 9