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 27 28 29 30 31 32 33 34 35 36
|
#include <iostream>
#include <string>
#include <vector>
struct pawn
{
int x, y ;
static constexpr const char* const pic = "BP" ;
};
pawn black_pawns[] = {{1,0},{1,1},{1,2},{1,3},{1,4},{1,5},{1,6},{1,7}}; //creates pawns
constexpr int N = 8 ;
std::ostream& print_board( std::ostream& stm = std::cout )
{
static const char* const empty = "OO" ;
static const std::vector<std::string> empty_row( N, empty ) ;
std::vector< std::vector<std::string> > board( N, empty_row ) ;
for( pawn p : black_pawns ) board[ p.x ][ p.y ] = pawn::pic ;
for( const auto& row : board )
{
for( const auto& s : row ) stm << ' ' << s ;
std::cout << "\n\n" ;
}
return stm ;
}
int main()
{
print_board() ;
}
|