My program draws 3 sides of the frame, I can’t draw 4. This code draws 3 sides. The right frame is drawn under the left one, I can’t draw it on the right.
#include <iostream>
using namespace std;
void print_hor()// Рисует строчку горизонтальной части
{
cout << "#";
}
void print_vert() // Рисует строчку вертикальной части
{
cout << endl << "#";
}
void print(int width, int height)
{
for (int i = 0; i < width; ++i)
{
print_hor();
}
for (int i = 0; i < height - 1; ++i)
{
print_vert();
if (i == height - 2)
{
for (int i = 0; i < width - 1; ++i)
{
print_hor();
}
}
}
}
int main()
{
int width, height;
cin >> width;
cin >> height;
// Вызов функции (не трогать)
print(width, height);
}
I tried to solve it through the for loop, but for some reason the right side is drawn under the left side. as a result, nothing works out.
New contributor
Андрей Лобанов is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3