// patternTest.cpp
#include <iostream>
bool pattern(int rows);
int main()
{
cout << "How many rows?>";
int rows;
cin >> rows;
if ( ! pattern(rows) )
cout << "No pattern available for "
<< rows << " rows." << endl;
return 0;
} // function main
bool pattern(int rows)
{
if ( rows < 1 || rows > 20 )
return false;
for ( int row = 0; row < rows; row++ )
{
int positionFirstAsterisk = 0;
if ( row % 2 == 1 )
positionFirstAsterisk = 2;
for ( int column = 0; column < 2*rows; column++ )
{
if ( (column - positionFirstAsterisk) % 4 == 0 )
cout << '*';
else
cout << ' ';
} // for column
cout << endl;
} // for row
return true;
} // function pattern