diff --git a/rectangle.cpp b/rectangle.cpp new file mode 100644 index 0000000..4f9c8c1 --- /dev/null +++ b/rectangle.cpp @@ -0,0 +1,37 @@ +#include + +using namespace std; + +void drawRectangle(int h, int w, char s = '*') { + if (h <= 0 || w <= 0) { + cout << "Помилка: висота та ширина повинні бути додатними числами!" << endl; + return; + } + + for (int i = 0; i < h; ++i) { + for (int j = 0; j < w; ++j) { + cout << s; + } + cout << endl; + } +} + +int main() { + + setlocale(0, ""); + cout << "=== Приклади малювання прямокутників ===" << endl; + + cout << "\nПрямокутник 5x10 зі зірочками (за замовчуванням):" << endl; + drawRectangle(5, 10); + + cout << "\nПрямокутник 3x8 з символом '#' :" << endl; + drawRectangle(3, 8, '#'); + + cout << "\nПрямокутник 4x12 з символом '@' :" << endl; + drawRectangle(4, 12, '@'); + + cout << "\nПрямокутник 2x6 з символом '+' :" << endl; + drawRectangle(2, 6, '+'); + + return 0; +} \ No newline at end of file