1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include <iostream>
#include <iomanip>
#include <list>
#include <vector>
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<long> > c = { { 1, 2, 3 }, { 3, 4 }, { 5 }, { 6, 7 }, { 5, 6, 7, 8 } } ;
print_seq2d(a) ;
print_seq2d( b, 3 ) ;
print_seq2d(c) ;
}
|