Exercise: Paint the American Flag Onto Standard Output¶
Description¶
Write a program to print the American flag, like so:
$ ./american-flag
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
==============================================
==============================================
==============================================
==============================================
==============================================
==============================================
The program does not simply output those lines as-is, like
std::cout << "* * * * * * ==================================" << std::endl;
Rather, it defines a function to compose the output:
void print_chars(char c, std::string sep, unsigned int n);
To print the line above, for example, the program would use that function like so:
print_chars('*', " ", 6);
cout << ' ';
print_chars('=', "", 34);