#include<iostream> struct bottle { int x = 0 ; int y = 0 ; // .... }; std::ostream& operator<< ( std::ostream& stm, const bottle& b ) { return stm << '(' << b.x << ',' << b.y << ')' ; } // adjust the values of these as required constexpr int NROWS = 8 ; constexpr int NCOLS = 6 ; constexpr int start_x = 25 ; constexpr int start_y = 15 ; constexpr int delta_x = 8 ; constexpr int delta_y = 11 ; using bottle_array_type = bottle[NROWS][NCOLS] ; // typedef bottle bottle_array_type[NROWS][NCOLS] ; void initialize_bottle_array( bottle_array_type& bottle_array ) { for( int row = 0 ; row < NROWS ; ++row ) for( int col = 0 ; col < NCOLS ; ++col ) { bottle_array[row][col].x = start_x + col * delta_x ; bottle_array[row][col].y = start_y + row * delta_y ; } } int main() { bottle_array_type bottle_array ; initialize_bottle_array(bottle_array) ; for( const auto& row : bottle_array ) { for( const bottle& b : row ) std::cout << b << ' ' ; std::cout << '\n' ; } }
Standard input is empty
(25,15) (33,15) (41,15) (49,15) (57,15) (65,15) (25,26) (33,26) (41,26) (49,26) (57,26) (65,26) (25,37) (33,37) (41,37) (49,37) (57,37) (65,37) (25,48) (33,48) (41,48) (49,48) (57,48) (65,48) (25,59) (33,59) (41,59) (49,59) (57,59) (65,59) (25,70) (33,70) (41,70) (49,70) (57,70) (65,70) (25,81) (33,81) (41,81) (49,81) (57,81) (65,81) (25,92) (33,92) (41,92) (49,92) (57,92) (65,92)