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
|
#include <iostream>
using namespace std;
void draw( int rows, int cols, char black, bool (*white)( int, int ) )
{
for ( int i = 0; i < rows; i++ )
{
for ( int j = 0; j < cols; j++ ) cout << ( white( i, j ) ? ' ' : black );
cout << '\n';
}
cout << '\n';
}
int main()
{
const int N = 10;
const char C = '*';
cout << "Under each other ...\n\n";
draw( N, N, C, []( int i, int j ){ return j > i ; } );
draw( N, N, C, []( int i, int j ){ return j < i ; } );
draw( N, N, C, []( int i, int j ){ return j + i >= N ; } );
draw( N, N, C, []( int i, int j ){ return j + i < N - 1; } );
cout << "\n\nNext to each other ...\n\n";
draw( N, 2 * N + 5, C, []( int i, int j ){ return j == i + 1 || j == N + 2 || i + j == 2 * N + 3; } );
}
|