codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <algorithm> #include <functional> #include <iterator> #include <iostream> #include <locale> struct Op { template <typename T, size_t Rows> bool operator()(const T (&arr)[Rows]) const { return std::adjacent_find(arr, arr + Rows, std::less_equal<T>()) == arr + Rows; } }; template <typename T, size_t Cols, size_t Rows> void transform(const T (&m)[Cols][Rows], bool (&arr)[Cols]) { std::transform(m, m + Cols, arr, Op()); } int main() { const size_t N = 4; const size_t M = 4; int m[N][M] = { {1,2,3,4}, {3,2,1,0}, {3,4,1,0}, {3,3,1,0} }; bool arr[N]; transform(m, arr); setlocale(LC_ALL, ""); std::copy(arr, arr+N, std::ostream_iterator<int>(std::cout, " ")); return 0; }
Private
[
?
]
Run code
Submit