I am required to output Hi in huge block letter which is enclosed in a box of * in C++. image of the output required So far I've only managed to figure out a basic way where I print each line by line, but is there any smarter way to do it?
Heres what I managed so far
#include <iostream>
using namespace std;
int main(){
cout << "**********************" << endl;
cout << "* *" << endl;
cout << "* HH HH II *" << endl;
cout << "* HH HH II *" << endl;
cout << "* HH HH II *" << endl;
cout << "* HH HH II *" << endl;
cout << "* HHHHHHHH II *" << endl;
cout << "* HH HH II *" << endl;
cout << "* HH HH II *" << endl;
cout << "* HH HH II *" << endl;
cout << "* HH HH II *" << endl;
cout << "* *" << endl;
cout << "**********************" << endl;
return 0;
}
You can make your program a bit easier to modify by using the symmetry of what you are printing:
#include <iostream>
using namespace std;
void n_lines(int n)
{
for (auto i = 0; i < n; i++)
cout << "* HH HH II *" << endl;
}
void star_line()
{
cout << "**********************" << endl;
}
void empty_line()
{
cout << "* *" << endl;
}
int main(){
star_line();
empty_line();
n_lines(4);
cout << "* HHHHHHHH II *" << endl;
n_lines(4);
empty_line();
star_line();
return 0;
}
This will produce the same output, but it's much easier to change the size and such.