fork download
#include 
#include 
#include 
#include 

template < typename SEQUENCE_2D >
void print_seq2d( const SEQUENCE_2D& a, int width = 2 )
{
    for( const auto& row : a )
    {
        for( const auto& v : row ) std::cout << std::setw(width) << v  ;
        std::cout << '\n' ;
    }
    std::cout << "------------\n" ;
}

int main()
{
    int a[][3] = { { 1, 2, 3 }, { 3, 4, 5 }, { 5, 6, 7 }, { 8, 9, 1 } } ;
    short b[][4] = { { 35, 16, 7, 8 } , { 3, 29, 2, 42 }, { 21, 32, 43, 54 } } ;
    std::list< std::vector > c = { { 1, 2, 3 }, { 3, 4 }, { 5 }, { 6, 7 }, { 5, 6, 7, 8 } } ;

    print_seq2d(a) ;
    print_seq2d( b, 3 ) ;
    print_seq2d(c) ;
}
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
 1 2 3
 3 4 5
 5 6 7
 8 9 1
------------
 35 16  7  8
  3 29  2 42
 21 32 43 54
------------
 1 2 3
 3 4
 5
 6 7
 5 6 7 8
------------