#include <iostream>
#include <iomanip>
int main()
{
constint n = 4 ;
int array[4][4] {};
constchar space = ' ' ;
// set some values to integers, others to spaces
for( int row = 0 ; row < n ; ++row )
{
for( int col = 0 ; col < n ; ++col )
{
if( row != col ) array[row][col] = row*n + col ; // integer value
else array[row][col] = space ; // space (implicit conversion from char to int)
}
}
// range based for loop http://www.stroustrup.com/C++11FAQ.html#forfor( constauto& row : array )
{
for( int v : row )
{
std::cout << std::setw(3) ;
if( v == space ) std::cout << space ; // if it is a space print a space
else std::cout << v ; // otherwise, print the integer value
}
std::cout << '\n' ;
}
}