#include <iostream>
usingnamespace std;
constint IMAX = 3 ; // down
constint JMAX = 17 ; // across
constchar BACKGROUND = '#';
constchar FOREGROUND = '*';
int main()
{
int i, j;
// Flood with background
char screen[IMAX][JMAX];
for ( i = 0; i < IMAX; i++ )
{
for ( j = 0; j < JMAX; j++ ) screen[i][j] = BACKGROUND;
}
// Move left to right, filling in the diagonal wiggles
i = IMAX - 1;
int istep = -1; // starting position and increment of i
for ( int j = 0; j < JMAX; j++ )
{
screen[i][j] = FOREGROUND;
i += istep; // next position of diagonal
if ( i == 0 || i == IMAX - 1 ) istep = -istep; // change direction at top or bottom
}
// Draw it
for ( i = 0; i < IMAX; i++ )
{
for ( j = 0; j < JMAX; j++ ) cout << screen[i][j];
cout << endl;
}
}
@OP Your coordinated approach is very simple, congratulations :)
Extend it as your requirement dicatates, perhaps by developing the pattern using 3 <string>'s repeating every 3rd or 4th column.